这是我的代码。所有的帮助将不胜感激。 PS我不是在做一个骗局或类似的东西,最上面的部分应该是个玩笑。为什么我的扫描仪不出现在我的for循环中?
import java.io. ; import java.util。;
public class ShoppingSpree//Nick
{
public static void main(String args[])
{
int maxitems = 3;
double damountofmoneywon = 100.00;
double moneyleft = damountofmoneywon;
for(moneyleft = 100.00; moneyleft == 0.00;)
{
System.out.println("You have won $100 for being the 1,000,000 visitor to this site.");
System.out.println("You may buy up to 3 items costing no more than $100.");
System.out.println("Enter the cost of your item: ");
Scanner itemonecost = new Scanner(System.in);
double ditemonecost = itemonecost.nextDouble();
if(ditemonecost <= moneyleft)
{
System.out.println("You have enough money for this item.");
moneyleft = moneyleft - ditemonecost;
}
else if(moneyleft == 0)
{
System.out.println("You have no more money");
break;
}
else
{
System.out.println("You don't have enough money, try again");
}
}
}
}
你在问什么? –
检查你的循环,它不增加任何东西。 –
你忘了问一个问题。 – Prateek