Results 1 to 5 of 5
  1. #1
    hayden06f4i is offline Senior Member
    Join Date
    Oct 2010
    Posts
    119
    Rep Power
    0

    Default Same issue as before....

    well, i have already assumedly failed this test, since i couldnt get the program to work in the time limit, so could someone please look this over and help me debug the errors that i can't figure out? I guess i done understand fully the set/get thing....

    Java Code:
    Sales.java:32: cannot find symbol
    symbol  : variable getCommission
    location: class Sales
                    getCommission );
                    ^
    SalesTest.java:10: cannot find symbol
    symbol  : class Commission
    location: class SalesTest
                    Commission mycommission = new Commission (
                    ^
    SalesTest.java:10: cannot find symbol
    symbol  : class Commission
    location: class SalesTest
                    Commission mycommission = new Commission (
                                                  ^
    3 errors
    TWO PROGRAMS
    Java Code:
    //Sales.java week 2 test Ex4.19 Sales Commission Calculator
    // calculates base salary of $200, plus sales commissions
    //of 9% of of their gross sales for the week
    import java.util.Scanner; //program uses Scanner
     
    public class Sales
    {
    	private String Commission; 
    	
    	//constructor initializes commission
    	public Sales ( String name )
    	{
    		Commission = name; // initializes commission
    	}// end constructor
    	
    	// method to set the commission
    	public void setCommission ( String name )
    	{
    		Commission = name; // store the course name
    	}// end method setcommission
    	
    	// method to retrieve the commission
    	public String getCommission ()
    	{
    		return Commission;
    	}// end method get commission
    	
    	// display welcome message
    	public void displayMessage ()
    	{
    		System.out.printf ( "Welcome to the Commission Calculator for\n%s\n\n",
    		getCommission );
    	}//end method display message
    	
    	public void determineCommission ()
    	{
    		//create Scanner to obtain input from user
    		Scanner input = new Scanner ( System.in );
    		
    		double basesalary = 200; //  base salary of $200
    		double totalsalary = 0; // total of base salary and commission
    		double sales = 0;
    		double totalsales = 0; // total amount of items sold
    		double Commission = 0; // amount of commission
    		
    		// processing phase
    		//prompt for input from user
    		System.out.print ( "\n Enter sold item amount or -1 to quit: ");
    		sales = input.nextDouble();
    		
    		// loop until sentinel value is read from user
    		while (sales != -1)
    		{
    			totalsales = totalsales + sales; // add sales to totalsales
    			
    			//prompt for input and read next sale item number
    			System.out.print ( "\n Enter sold item amount or -1 to quit: ");
    			sales = input.nextDouble();
    		} // end while
    		
    		//termination phase
    		//if user entered at least one sales item
    		if (totalsales != 0)
    		{
    			// calculate commission
    			Commission = (totalsales / .09); // commission is 9% of total sales
    			totalsalary = Commission + basesalary; //total salary is commission + $200
    			
    			//display total sales, commission amount, and total salary
    			System.out.printf ( "\nTotal sales were : $%f\n", totalsales );
    			System.out.printf ( "\nTotal Commission is : $%f\n", Commission );
    			System.out.printf ( "\nTotal Salary is : $%f\n", totalsalary );
    		} // end if
    		
    		else // no sales were made.....
    			System.out.println ( "No Sales were made, Sorry." );
    	}// end method determinecommission
    }// end class Sales
    Java Code:
    // TEST1 ex4.19 SalesTest.java
    // Create Sales object and invoke its determinecommission method
    
    public class SalesTest
    {
    	public static void main ( String [] args )
    	{
    		//create Sales object mySales and
    		//pass commission to constructor
    		Commission mycommission = new Commission (
    			"Hayden Martz" );
    		
    		mycommission.displaymessage (); // display welcome message
    		mycommission.determineCommission (); // determine commission amount
    	} // end main
    } // end class SalesTest.java

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by hayden06f4i View Post
    well, i have already assumedly failed this test, since i couldnt get the program to work in the time limit, so could someone please look this over and help me debug the errors that i can't figure out? I guess i done understand fully the set/get thing....

    Java Code:
    SalesTest.java:10: cannot find symbol
    symbol  : class Commission
    location: class SalesTest
                    Commission mycommission = new Commission (
                    ^

    The error message is pretty simple and straight-forward and is telling you exactly what's wrong: that it can't find a class named "Commission". For that matter, neither can I in the code that you've posted.


    Java Code:
    Sales.java:32: cannot find symbol
    symbol  : variable getCommission
    location: class Sales
                    getCommission );
                    ^
    And here it's telling you that it can't find a variable named getCommission. It's messing up because you're trying to use getCommission like a variable rather than call it as a method with parenthesis () on the end. So add the parenthesis.
    Last edited by curmudgeon; 11-08-2010 at 01:21 AM.

  3. #3
    hayden06f4i is offline Senior Member
    Join Date
    Oct 2010
    Posts
    119
    Rep Power
    0

    Default

    i tried changing the name of the class from "Sales" to "Commission", but that didn't change the errors. sorry for the bad code, this is my second week into this'

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by hayden06f4i View Post
    i tried changing the name of the class from "Sales" to "Commission", but that didn't change the errors. sorry for the bad code, this is my second week into this'
    Maybe you made the wrong change (hint: change Commission into Sales)

  5. #5
    hayden06f4i is offline Senior Member
    Join Date
    Oct 2010
    Posts
    119
    Rep Power
    0

    Default

    curmudgeon,

    it simply came down to those parentheses i missed putting in.....man im SO mad!

    I really appreciate your help though!

    Hopefully i won't repeat that mistake. Thank you.

Similar Threads

  1. nio issue
    By mawandiadeepak in forum Networking
    Replies: 2
    Last Post: 03-17-2010, 05:23 AM
  2. JSF issue
    By premjo in forum New To Java
    Replies: 0
    Last Post: 02-14-2010, 02:19 PM
  3. Issue
    By FlashNinja in forum New To Java
    Replies: 20
    Last Post: 11-28-2009, 09:44 PM
  4. PDF Box issue
    By jazz2k8 in forum Advanced Java
    Replies: 0
    Last Post: 03-20-2009, 11:04 AM
  5. Issue
    By chaitu444 in forum New To Java
    Replies: 2
    Last Post: 11-06-2007, 07:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •