我正在C#中执行一个旅行控制台应用程序,并且无法确定将方法和方程式放在哪里以使应用程序运行。我需要计算每加仑的MPG和成本。我是编程新手,正在画空白。我附加了两张开始控制台窗口应该看起来像什么以及结果窗口看起来像的图片。如果任何人都可以告诉我,我应该去的方向我会很感激。 console beginning user input window Result Console Window如何将方法和方程式添加到类中
类W8M2A1_CTripAppProgram
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace W8M2A1_TripApp
{
class W8M2A1_CTripAppProgram
{
static void Main(string[] args)
{
//Display Welcome Message
Console.WriteLine("Welcome to Trip Fuel Cost Calculator- Valentina Woodson March 4, 2016 (v.1)");
Console.WriteLine("---------------------------------------------------------------------------\n\n");
//Prompt for destination input
Console.Write("Enter Trip Destination City: ");
string yourDes = Console.ReadLine();
Console.WriteLine("\n\n");
//Prompt for trip mileage
Console.Write("Enter Rount Trip Mileage: ");
double roundtMil = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("\n\n");
//Prompt for Gallons used
Console.Write("Enter Number of Gallons Consumed for the Trip: ");
double galCon = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("\n\n");
//Prompt for fuel Cost per Gallon
Console.Write("Enter Fuel Cost Per Gallon: ");
double fuelpGal = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("\n\n");
//Display information
Console.WriteLine("Your Trip Cost Are Shown in the Following:");
Console.WriteLine("-------------------------------------------\n");
Console.WriteLine("\n\n");
Console.WriteLine("Please press any key to exit");
Console.ReadKey();
}
}
}
类旅行:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace W8M2A1_TripApp
{
class Trip
{
// Declare data items: destination, round trip mileage, gallons consumed, full cost per gallon
string yourDes;
private double roundtMil;
private double galCon;
private double fuelpGal;
private double mpg;
}
}