进行语法分析时已到达文件结尾
发布网友
发布时间:2022-04-29 17:46
我来回答
共1个回答
热心网友
时间:2023-10-25 15:16
排除错误后的代码如下:
/*********************************************
*Soda.java
*Ruining Wang
*10/29/2011
*This is program to use Soda Machine
*********************/
import java.util.Scanner;
public class Soda
{
public static void main (String[] args)
{
Scanner stdIn = new Scanner (System.in);
double temperature = 0;
double priceOfSoda = 0;
double money = 0;
double change = 0;
System.out.println("Enter the temperature in Fahrenheit(one decimal place)");
temperature = stdIn.nextDouble();
if(temperature < 50.0)
{ priceOfSoda = 0.50;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 50 && temperature <= 60)
{ priceOfSoda = 0.55;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 61 && temperature <= 65)
{ priceOfSoda = 0.60;
System.out.print("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 66 && temperature <= 70)
{ priceOfSoda = 0.65;
System.out.print("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 71 && temperature <= 75)
{ priceOfSoda = 0.75;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 76 && temperature <= 80)
{ priceOfSoda = 0.80;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 81 && temperature <= 85)
{ priceOfSoda = 0.85;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else if(temperature >= 86 && temperature <= 90)
{ priceOfSoda = 0.90;
System.out.println("the price of Soda:$"+priceOfSoda);
}
else
{ System.out.println("the price of Soda:"+1.00);
}
System.out.println("Enter the money you input(up to $1.oo)");
money = stdIn.nextDouble();
change = money - priceOfSoda;
if(money >= priceOfSoda)
{ System.out.println("the amount of change :$"+change);
}
else
{ System.out.println("The money you enter is not enough");
}
}
}