Question

Java I - Write a program that will use static methods as described in the specifications below. U...

Java I - Write a program that will use static methods as described in the specifications below. Utilizing the if and else statements, write a program which will calculate a commission based on a two-tiered commission plan of 2% and 5% paid on amounts of $10,000 or less, or over $10,000 in monthly sales by a sales force paid on a commission basis. Use the output specifications below.

---

(Please make detailed comments so I can better understand the code. Thank you!)

Specifications

  • There will be two classes (separate files) in this program. The class containing the main method will be called Commission. All methods will be called from the main method. The second class (file) will be calledComCalc and will contain all of the methods created below.

  • Prompt the user to input the total monthly sales. That number will be input from the keyboard.

  • Commission is paid at the rate of 2% on any amount of $10,000 or less, in sales. Anyone selling over $10,000 is paid at the rate of 5% on the total monthly sales amount.

  • Use the if, else if, and else statements where necessary, to determine the appropriate rate for the amount of the total monthly sales, then calculate the commission following the if/else structure.

  • Output the commission rate, total monthly sales amount, and the commission amount and use appropriate labels for each (see output format below).

  • Use text labels on the output which make it clear what information is being displayed. Do not simply use single words like Commission or Total. Single words such as those are not descriptive enough.

---

Constructing the Methods

Create the following methods in the CommCalc class (separate file):

  1. inputTotalSales()

    • This method will display a prompt for the user to enter the total amount of the monthly sales.

    • This method will return the amount of the monthly sales that the user entered.

    • This method does not have parameters.

  2. setCommRate()

    • This method will accept an argument which will be the total monthly sales amount entered by the user and returned to the main method.

    • This method will determine the appropriate commission rate based on whether the monthly sales were over $10,000 or not. Setting the commission rate will be its only task.

    • This method will return the commission rate.

  3. calcCommAmount()

    • This method will accept the commission rate and the amount of monthly sales entered by the user and returned to the main method, and will calculate the amount of the commission.

    • This method will return the amount of commission.

  4. displayCommResults()

    • This method will accept the sales amount, the commission rate, and the amount of commission sent from the mainmethod.

    • This method will display the three items above with the output labels shown in the Output Format below.

    • This will be a void method

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//ComCal.java

import java.util.Scanner;

public class ComCalc {
public double inputTotalSales() {
   double sale;
   Scanner in = new Scanner(System.in);
   System.out.print("Enter the total amount of the monthly sales : ");
   sale = in.nextDouble();
   in.close();
   return sale;
}
  
public double setCommRate(double sale) {
   if(sale<=10000)return 0.02;
   return 0.05;
}
public double calcCommAmount(double commissionRate,double sale) {
   return commissionRate*sale;
}
public void displayCommResults(double sale , double commissionRate , double commission) {
   System.out.println("Sales amount : $"+sale);
   System.out.println("commission Rate : "+commissionRate);
   System.out.println("commisssion Amount : $"+commission);
}
}
//Commission.java

import array.ComCalc;

public class Commission {
   public static void main(String args[]) {
       ComCalc cal = new ComCalc();
       double sale;
       double commissionRate;
       double commission;
      
       sale = cal.inputTotalSales();
       commissionRate = cal.setCommRate(sale);
       commission = cal.calcCommAmount(commissionRate, sale);
       cal.displayCommResults(sale, commissionRate, commission);
      
   }
}
//sample output

sterminated> Commission [Java Application] C:Program Files Javaljdk1.8.0_151 Enter the total amount of the monthly sales 1000

Add a comment
Know the answer?
Add Answer to:
Java I - Write a program that will use static methods as described in the specifications below. U...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use stacks to implement a program in JAVA that will prompt the use to type a...

    Use stacks to implement a program in JAVA that will prompt the use to type a word, then print that word in reverse order of letters, then ask the user for another word, and so on. The program should terminate when the user enters "STOP" in upper case. Your deliverables shall include: class and method specifications; class and method definitions; at test class with at least two @test methods.

  • Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate...

    Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...

  • Java CSC252   Programming II    Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that...

    Java CSC252   Programming II    Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...

  • Write a complete Java program called "AtmSimDoLoop" (without the quotation marks) according to the following specifications....

    Write a complete Java program called "AtmSimDoLoop" (without the quotation marks) according to the following specifications. It should use a do-while loop to prompt the user with the following starting prompt (without the horizontal lines) until the user enters 4 to quit. The program should start with an initial account balance, which you can set to any legitimate double value. Prompt the user with the following prompt (without the horizontal lines). Enter the number of your desired transaction type. Deposit...

  • JAVA Programming scenario: write a program that will prompt a user for 10 legendary people/characters. After...

    JAVA Programming scenario: write a program that will prompt a user for 10 legendary people/characters. After the entries are complete the program will display all 10 characters information. requirements: Create a user-defined class with the fields below: - First - Last - Nickname - Role - Origin Create a main-source that will use the user-defined class and do the prompting. Create get/set methods in your user-defined class and methods in the main-source.

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Java Program 4: Methods Purpose: To practice using both void and value-returning methods and understand when,...

    Java Program 4: Methods Purpose: To practice using both void and value-returning methods and understand when, where, and how to use them. The following problem employs the use of both void and value-returning methods: (Be sure to start with an algorithm to help you organize your ideas and provide a blueprint as to how to approach the problem. Think about what kind of return type your method will need. Carefully examine and follow ALL the program specifications (for full credit)....

  • Random Number Generation and Static Methods Write a program that simulates the flipping of a coin...

    Random Number Generation and Static Methods Write a program that simulates the flipping of a coin n-times to see how often it comes up heads or tails. Ask the user to type in the number of flips (n) and print out the number of times the coin lands on head and tail. Use the method ‘random()’ from the Math class to generate the random numbers, and assume that a number less than 0.5 represents a tail, and a number bigger...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT