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 4 of 4

Thread: Is this what my exercise want?

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is this what my exercise want?

    Exercise:
    Create a Class named Commission that includes three Variables: a double sales figure, a double commission rate, and an int commission rate. Create two overloaded methods named computeCommission( ). The first method takes two double parameters representing sales and rate, multiplies them, and then displays the results. The second commission takes two parameters: a double sales figure and an integer commission rate. This method must divide the commission rate by 100.0 before multiplying by the sales figure and displaying the commission. Supply appropriate values for the variables, and write a main( ) method that tests each overloaded method. Save the application as Commission.java.

    Does this code do what the exercise wants?

    public class Commission
    {
    public static void main(String[] args)
    {
    double Sales = 2000.75;
    double Rate = 15.50;
    int rate = 16;
    computeCommission(Sales, Rate);
    computeCommission(Sales, rate);
    }
    public static void computeCommission(double Sales, double Rate)
    {
    System.out.println("Total Sales Commission this Term: " + (Sales * Rate));
    }
    public static void computeCommission(double Sales, int rate)
    {
    System.out.println("Today's Sales Commission: " + ((rate / 100.0) * Sales));
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Is this what my exercise want?

    Does it compile and execute and output the correct results? This I guess its good.

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Is this what my exercise want?

    ----jGRASP exec: javac -g Commission.java

    ----jGRASP: operation complete.


    ----jGRASP exec: java Commission

    Total Sales Commission this Term: 31011.625
    Today's Sales Commission: 320.12

    ----jGRASP: operation complete.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Is this what my exercise want?

    Are those the correct results?

Similar Threads

  1. Replies: 4
    Last Post: May 15th, 2011, 06:03 AM
  2. [SOLVED] Exercise for study course help?
    By SweetyStacey in forum Object Oriented Programming
    Replies: 12
    Last Post: April 25th, 2010, 02:01 PM
  3. JAVA exercise
    By gmilan in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 13th, 2010, 02:30 PM
  4. Cash Register Exercise
    By Consus in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 19th, 2010, 11:52 PM
  5. Exercise problems
    By Virgildonatifan in forum Java Theory & Questions
    Replies: 0
    Last Post: February 14th, 2010, 04:12 AM