我无法在C#中为我的某个作业输入两个不同的输入值。它似乎不想用我设置它的方式进行调试。
到目前为止,这是我设置它的方式,它仍然不适用于我。
static void Main(string[] args)
{
float milespergallon, milestraveled, gallonsofgasused;
string textLine;
Console.Write("What is the total miles traveled and gallons of gas used? ");
textLine = Console.ReadLine(); // read in text from console
milestraveled and gallonsofgasused = float.Parse(textLine); // convert text into floating point
milespergallon = miles / gallons; // calculate mpg = miles / gallons
Console.Write("Miles Per Gallon: ");
Console.WriteLine(milespergallon.ToString());// Output miles per gallon to console
Console.ReadLine(); // Wait for return key press
}
答案 0 :(得分:1)
double milespergallon, milestraveled, gallonsofgasused; // don't fiddle with float
string textLine;
Console.Write("What is the total miles traveled? ");
textLine = Console.ReadLine(); // read in text from console
milesTraveled = double.Parse(textLine);
Console.Write("What is the total gallons of gas used? ");
textLine = Console.ReadLine(); // read in text from console
gallonsOfGasUsed= double.Parse(textLine);
...