それで、プログラミング教室ラボの入門用に自動販売機を作ることになっています。これまでのところ、これが私の Java コードの外観です。
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 です。何らかの理由でプログラムが Blue J で起動しません。Eclipse が推奨されていることはわかっていますが、Blue J でこのラボを終了したいと考えています。ヒントはありますか?