Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ask the user for the sales amount. The amount need to be passed to a function. T

ID: 3830064 • Letter: A

Question

Ask the user for the sales amount. The amount need to be passed to a function. The function is to calculate and return the commission based on the following:

For sales amounts over $20,000, the commission rate is 20%.

For sales amounts between $10,000 and $20,000 (inclusive), the commission rate is 15%.

For sales amounts less than $10,000, the commission rate is 10%.

To calculate the commission, the sales amount needs to be multiplied by the commission rate.

Make sure to suppress all output from the function so that the results are only displayed in the program that called the function.

Explanation / Answer

C++ Program :

#include <iostream>
using namespace std;

double commission(double amt){
   if(amt>20000){
       return (amt*20)/100;
   }
   if(amt>10000&&amt<=20000){
       return (amt*15)/100;
   }
   return (amt*10)/100;
}

int main() {
   // your code goes here
   printf("Enter the sales amount ");
   float salesAmount;
   scanf("%f",&salesAmount);
   printf("Commission is %f ",commission(salesAmount));
   return 0;
}

OUTPUT :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote