Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Could someone help me find my errors on this program?? (homework)

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Could someone help me find my errors on this program?? (homework)

    Sub program
    public class CashRegister {
    	public CashRegister() {
    		purchase = 0;
    		payment = 0;
    	}
    	public void recordPurchase(double amount){
    		double purchase = purchase + amount;
    	}
    	public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
    		double 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;
     
    	}
    Errors for sub program:
    --------------------Configuration: CashRegister - jre6 <Default> - <Default>--------------------
    C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegister.java:9: ')' expected
    	public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
    	                                    ^
    C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegister.java:9: ';' expected
    	public void enterPayment(int dollars; int quarters; int dimes; int nickels; int pennies){
    	                                                                                       ^
    2 errors
     
    Process completed.

    Main program
    public class CashRegisterTester{
    	public static void main(String[] args) {
    		CashRegister register = new CashRegister();
    		register.recordPurchase(0.75);
    		register.recordPurchase(1.50);
    		register.enterPayment(2,0,5,0,0);
    		System.out.print("Change = ");
    		System.out.println(register.giveChange());
    	}
    }

    Errors for main program:
    --------------------Configuration: CashRegisterTester - jre6 <Default> - <Default>--------------------
    C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegisterTester.java:3: cannot find symbol
    symbol  : class CashRegister
    location: class CashRegisterTester
    		CashRegister register = new CashRegister();
    		^
    C:\Users\Name\Documents\JCreator Pro\MyProjects\CashRegister\src\CashRegisterTester.java:3: cannot find symbol
    symbol  : class CashRegister
    location: class CashRegisterTester
    		CashRegister register = new CashRegister();
    		                            ^
    2 errors
     
    Process completed.

    Please help!
    I get the feeling that the main just can't seem to find the sub.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Could someone help me find my errors on this program?? (homework)

    See the method declaration on line 9 of CashRegister - parameters are separated by comma's and not semi-colons.

  3. The Following User Says Thank You to copeg For This Useful Post:

    r19ecua (April 20th, 2011)

  4. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Could someone help me find my errors on this program?? (homework)

    Quote Originally Posted by copeg View Post
    See the method declaration on line 9 of CashRegister - parameters are separated by comma's and not semi-colons.
    Thank you so much!!!

Similar Threads

  1. Replies: 3
    Last Post: February 23rd, 2011, 01:27 AM
  2. My program doesnt want to do its math point my errors out please
    By Redlight in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 31st, 2010, 01:56 PM
  3. Help with Cannot Find Symbol Variable errors
    By skboone in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 10:52 AM
  4. need help with homework program...thanks
    By robertsbd in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 5th, 2010, 03:12 PM