所以我應該爲我的介紹編程類實驗室做一個自動售貨機。到目前爲止,這是我的Java代碼的樣子。基本的Java程序不會運行在Blue-J
import java.util.Scanner;
public class VendingMachine
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
final int quarter = 25;
final int dime = 10;
final int nickel = 15;
int cost = keyboard.nextInt();
int totalChange = 100 - cost;
int totalQuarters= totalChange/quarter;
totalChange = totalChange % quarter;
int totalDimes = totalChange/dime;
totalChange = totalChange % dime;
int totalNickels = totalChange/nickel;
totalChange = totalChange % nickel;
System.out.print("Enter Price for your item" + "30");
}
}
我需要做的是這個。
Enter a price for item (from 25 cents to a dollar, in 5-cent increments): 45
You bought and item for 45 cents and gave me a dollar, so your change is
2 quarters,
0 dimes, and
1 nickels.
隨着值30,65和100。出於某種原因,在藍J..so程序將無法啓動,我知道Eclipse的建議,但我認爲我要完成這個實驗與藍Ĵ,任何人有任何提示?
我們不是在這裏爲他人填寫作業! (因爲作業標籤已被棄用...沒有意義!) – t0mm13b