我正在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;
}
}