#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Sales Commission - and Test application


    Please I need help. I have completed the code for this assignment and the test. However, for the Sales app it only lets me enter an amount for item four and not 1 -4. For the Sales Test I keep getting an error in the code and don't know how to fix it. Please help!!!
    PHP Code:
    import java.util.Scanner;

    public class 
    Sales
    {
       
    // calculate the sales for items sold
       
    public static void main(String[] args )
       { 
          
    Scanner input = new ScannerSystem.in );

          
    double gross 0.0earnings// total earnings
          
    int item 0numberSold// item number sold,

          
    while ( item 4)
        
             
    item++;

             
    // prompt the user for input and obtain item sold from user
             
    System.out.printf"Enter number sold of item #%d: "item );
             
    numberSold input.nextInt();

            
    // determine gross sales of each item and add to the total sold
            
    if ( item == 1)
               
    gross gross+numberSold 239.99;
            else if ( 
    item == )
               
    gross gross+numberSold 129.75;
            else if ( 
    item == )
               
    gross gross+numberSold 99.95;
            else if ( 
    item == )
               
    gross gross+numberSold 350.89;

            
    earnings = (0.09 gross) + 200// calculates earnings
            
    System.out.printf"Earnings this week are: $%.2f\n"earnings );   
     }
    // end method 
    }// end class Sales 
    Here is the Test and the error message.


    PHP Code:
    public class SalesTest
    {
       
    // main method begins program execution
       
    public static void mainString[] args )
       { 
          
    // create Sales object
          
    Sales application = new Sales(); 
          
    application.calculateSales();
        } 
    // end main
    // end class SalesTest 
    SalesTest.java:11: cannot find symbol
    symbol : method calculateSales()
    location class Sales
    application.calculateSales();
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    74
    Rep Power
    18
    You are missing parentheses for your while loop, so the item++ is run 4 Times and then the program asks user input. Why dont you use a for loop btw?

    As for the test program: you dont have a method calculateSales()
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Got it!!!


    Originally Posted by Aurum84
    You are missing parentheses for your while loop, so the item++ is run 4 Times and then the program asks user input. Why dont you use a for loop btw?

    As for the test program: you dont have a method calculateSales()
    Thank you very much! I got it.

IMN logo majestic logo threadwatch logo seochat tools logo