Question

c++ class problem Topics if/else if Description Write a program that calculates a sales person’s monthly...

c++ class problem

Topics

if/else if

Description

Write a program that calculates a sales person’s monthly commission. The program asks the user to enter the total sales amount for the month. It calculates the commission on the basis of the sales amount. Then, it displays a report including the sales amount and the commission earned. The commission is computed using the following:

15% commission for the first $2,000.00 sales

20% commission for the next $1,000.00 sales

25% commission for the next    $500.00 sales

30% commission for the next    $500.00 sales

35% commission for the remaining sales

Requirements

Use the if/else if statement (not multiple if statements)

Test Data

Test the assignment by performing the following test runs with the test data shown:

Input Test Run 1

Enter Sales Amount: 1500.00

Output Test Run 1

Sales Amount:            1500.00

Commission Earned:   225.00

Input Test Run 2

Enter Sales Amount: 2500.00

Output Test Run 2

Sales Amount:            2500.00

Commission Earned:       400.00

Input Test Run 3

Enter Sales Amount: 3500.00

Output Test Run 3

Sales Amount:            3500.00

Commission Earned:   625.00

Input Test Run 4

Enter Sales Amount: 4000.00

Output Test Run 4

Sales Amount:            4000.00

Commission Earned:       775.00

Input Test Run 4

Enter Sales Amount: 4500.00

Output Test Run 4

Sales Amount:            4500.00

Commission Earned:       950.00

Submit

Copy the following in a file and submit that file:

Outputs from test runs

All the C/C++ source code

Sample Code

/*

The code below shows only a part of an if /else if statement that calculates the commission amount from the sales amount. The if/else if statement below needs to be completed by adding additional if else components. In the statement below, the variable sales contains the sales amount and the variable commission the commission amount. Both the sales and commission are variables of type double.

*/

if (sales <= 2000.00)

{

            commission = .15 * sales;

}

else if (sales <= 3000.00)

{

            commission = (.15 * 2000.00) + ( (sales – 2000.00) * .20 );

}

else if (sales <= 3500.00)

{

       commission = (.15 * 2000.00) + (.20 * 1000.00) + ( (sales – 3000.00) * .25 ) ;

}

.

.

.

else

{

}

Homework Answers

Answer #1
#include <iostream>

using namespace std;

int main()
{
   double sales, commission;
   cout<<"Enter Sales Amount: ";
   cin>>sales;
   
   cout<<"Sales Amount:            "<<sales<<endl;
   
   if (sales <= 2000.00)
   {
        commission = .15 * sales;
   }
   else if (sales <= 3000.00)
   {
        commission = (.15 * 2000.00) + ( (sales - 2000.00) * .20 );
   }
   else if (sales <= 3500.00)
   {
      commission = (.15 * 2000.00) + (.20 * 1000.00) + ( (sales - 3000.00) * .25 ) ;
   }
   else if(sales <= 4000.00)
   {
      commission = (.15 * 2000.00) + (.20 * 1000.00) + (.25 * 500.0) + ((sales - 3500.00) * .30);
   }
   else{
      commission = (.15 * 2000.00) + (.20 * 1000.00) + (.25 * 500.0) + (.30 * 500.0) + ((sales - 4000.00) * .35);
   }
   
   cout<<"Commission Earned:   "<<commission<<endl;
    return 0;
Know the answer?
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
Similar Questions
C++ class homework Topics If/Else statement Description    Write a program that determines the larger of...
C++ class homework Topics If/Else statement Description    Write a program that determines the larger of the two numbers provided by the user. The program asks the user to enter a number. Then it asks the user to enter another but a different number. Then, it determines the larger of the two numbers and displays it to the user. (If the user happens to enter the two numbers the same, the program may report either of the two numbers as...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's profit (or loss) within a certain period of time. 1) First, the program need to get user's name, the stock's code, number of shares and the price he/she purchased the stock, it also asks the user for the price he/she sold the stock later on. The program then compute the following: The amount of money the customer paid for the stock. The amount of...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics...
Topics Arrays Accessing Arrays Description Write a C++ program that will display a number of statistics relating to data supplied by the user. The program will ask the user to enter the number of items making up the data. It will then ask the user to enter data items one by one. It will store the data items in a double array. Then it will perform a number of statistical operations on the data. Finally, it will display a report...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of...
(C language) <stdio.h> decisions (else if or switch) Write a program to calculate the average of the 2 highest numbers entered. Ask the user to enter 3 integers, determine which 2 integers are the 2 highest, and then calculate and display the average of the 2 highest numbers. Format the answer to 2 decimal places. The numbers can be entered in any sequence - lowest to highest, highest to lowest, or completely random. A decision block will be necessary to...
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
(Use Java ) please write comment on every line I need to understand the code Problem...
(Use Java ) please write comment on every line I need to understand the code Problem Description: Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle, as shown in the Figure. (Hint: A point is in the rectangle if its horizontal distance...
Use a few sentences to describe the problem given below . Also, Identify the nouns and...
Use a few sentences to describe the problem given below . Also, Identify the nouns and verbs used in the below project descriptions.  Identified nouns, list the ones that are necessary to define variables in your program. For each variable, specify its name, data type, and what information it is used to store. Write the pseudo code algorithm (i.e. algorithm steps) to solve this problem. (For the base salaries and commission rates use constants instead to keep these values. Use the...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a Java program that Reads baseball data in from a comma delimited file. Each line...
Write a Java program that Reads baseball data in from a comma delimited file. Each line of the file contains a name followed by a list of symbols indicating the result of each at bat: 1 for single, 2 for double, 3 for triple, 4 for home run, o for out, w for walk, s for sacrifice Statistics are computed and printed for each player. EXTRA CREDIT (+10 points); compute each player's slugging percentage https://www.wikihow.com/Calculate-Slugging-Percentage Be sure to avoid a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT