Results 1 to 5 of 5
Thread: Same issue as before....
- 11-08-2010, 01:02 AM #1
Senior Member
- Join Date
- Oct 2010
- Posts
- 119
- Rep Power
- 0
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....
TWO PROGRAMSJava 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
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 SalesJava 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
- 11-08-2010, 01:17 AM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
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.
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.Java Code:Sales.java:32: cannot find symbol symbol : variable getCommission location: class Sales getCommission ); ^Last edited by curmudgeon; 11-08-2010 at 01:21 AM.
- 11-08-2010, 01:19 AM #3
Senior Member
- Join Date
- Oct 2010
- Posts
- 119
- Rep Power
- 0
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'
- 11-08-2010, 01:28 AM #4
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
- 11-08-2010, 01:49 AM #5
Senior Member
- Join Date
- Oct 2010
- Posts
- 119
- Rep Power
- 0
Similar Threads
-
nio issue
By mawandiadeepak in forum NetworkingReplies: 2Last Post: 03-17-2010, 05:23 AM -
JSF issue
By premjo in forum New To JavaReplies: 0Last Post: 02-14-2010, 02:19 PM -
Issue
By FlashNinja in forum New To JavaReplies: 20Last Post: 11-28-2009, 09:44 PM -
PDF Box issue
By jazz2k8 in forum Advanced JavaReplies: 0Last Post: 03-20-2009, 11:04 AM -
Issue
By chaitu444 in forum New To JavaReplies: 2Last Post: 11-06-2007, 07:49 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks