Sub: No errors listed / seen
public class CashRegister { public CashRegister() { purchase = 0; payment = 0; } public void recordPurchase(double amount){ purchase = purchase + amount; } public void enterPayment(int dollars, int quarters, int dimes, int nickels, int pennies){ payment = dollars + quarters*QUARTER_VALUE + dimes*DIME_VALUE + nickels*NICKEL_VALUE + pennies*PENNY_VALUE; } public double giveChange() { double change = payment - purchase; purchase = 0; payment = 0; return change; } private double purchase; private double payment; public static final double QUARTER_VALUE = 0.25; public static final double DIME_VALUE = 0.1; public static final double NICKEL_VALUE = 0.05; public static final double PENNY_VALUE = 0.01; }
Main (Scanner)
import java.util.Scanner; public class InputTester { public static void main(String [] args) { Scanner in = new Scanner(System.in); CashRegister register = new CashRegister(); System.out.print("Enter price: "); double price = in.nextDouble(); register.recordPurchase(price); System.out.print("Enter dollars: "); int dollars = in.nextInt(); System.out.print("Enter quarters: "); int quarters = in.nextInt(); System.out.print("Enter dimes: "); int dimes = in.nextInt(); System.out.print("Enter nickels: "); int nickels = in.nextInt(); System.out.print("Enter pennies: "); int pennies = in.nextInt(); register.enterPayment(dollars, quarters, dimes, nickels, pennies); System.out.print("Your change is: "); System.out.println(register.giveChange()); } }
Errors on main
--------------------Configuration: JDK version 1.6.0_24 <Default>-------------------- C:\Program Files (x86)\Xinox Software\JCreator LE\MyProjects\School\InputTester\InputTester.java:5: cannot find symbol symbol : class CashRegister location: class InputTester CashRegister register = new CashRegister(); ^ C:\Program Files (x86)\Xinox Software\JCreator LE\MyProjects\School\InputTester\InputTester.java:5: cannot find symbol symbol : class CashRegister location: class InputTester CashRegister register = new CashRegister(); ^ 2 errors Process completed.