Question

In: Computer Science

Write a program that contains 2 functions. Program will call a function named calc_commission that prompt...

Write a program that contains 2 functions. Program will call a function named calc_commission that prompt the user to enter the sales amount and computes and prints with a description the commission paid to salesperson as follows: 10% for sales amount less than $2,000.00, 15% for sales amount less than $10,000.00 and 20% for sales amount less than $20,000.00, then function calc_commission calls another function name assign_base_salary() to ask the user to enter each of 5 salesperson’s base salary , add the salary and commission earned and return to main program to print with a description the total of commission plus base salary. NEED THIS IN C++

Solutions

Expert Solution

#include <iostream>
using namespace std;

void assign_base_salary(double comm,double* salary)
{
    double temp;
    for (int i = 1;i<=5;i++)
    {
        cout<<"Enter salary of salesperson #"<<i<<" : ";
        cin >> temp;
        salary[i] = temp + comm;
    }
}
double* calc_commission()
{
    cout<<"Enter sales amount : ";
    double sales,comm;
    cin>>sales;
    if(sales<2000)
        comm = 0.1*sales;
    else if(sales<10000)
        comm =  0.15*sales;
    else if(sales<20000)
        comm = 0.2*sales;
    else
       {
           cout<<"Invalid amount";
           exit(0);
       }
    cout<<"Commission for salesperson : "<<comm<<" $\n";
    static double salary[5];
    assign_base_salary(comm,salary);
    return salary;
}
int main()
{
    
    double *finalpay;
    finalpay = calc_commission();
    for (int i = 1;i<=5;i++)
    {
        cout<<"Final pay of salesperson #"<<i<<" : "<<*(finalpay+i)<<" $\n";
    }
    return 0;
}

Related Solutions

Write a program that contains the following Write a function copies with two int parameters, named...
Write a program that contains the following Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n.  The function should then copy the value in x to every position in the array. The function should return a pointer to the new array. In the main function, call the copies function from part 1. with size 5 and value -1.  Output the resulting array to the screen, and deallocate the array....
Using Java, write a program named MyAngles that will prompt the user for the measure of...
Using Java, write a program named MyAngles that will prompt the user for the measure of the three sides of a triangle and then reports the measurement of each interior angle of the triangle and the area of the triangle.
Exercise: Write a program named factorial.py that contains the following two functions: def while_factorial(num) def for_factorial(num)...
Exercise: Write a program named factorial.py that contains the following two functions: def while_factorial(num) def for_factorial(num) These should calculate the factorial of a given number represented by the argument num using a while loop and a for loop respectively.
Write the following easy Python functions: 1) Write the function named roundDollars(). The function has one...
Write the following easy Python functions: 1) Write the function named roundDollars(). The function has one input, a String named amountStr which consists of a dollar-formatted amount, such as "$ 1,256.86". The returned value is an int representing the number of rounded "dollars" in the amount, (1257 in the sample shown here). You will need to scrub, format and parse the input, then use arithmetic to determine how many rounded dollars the amount contains. roundDollars("$ 1,256.86") → 1257 roundDollars("$ 0.42")...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the maximum number (as integer) Store a multiplication table for all combinations (with some specific eliminations) of value 0 through the maximum number (being entered) into a 2-D array Write a method named printTable to print out the MulitTable, with the following header, public static void printTable(int[][] multitable) In printTable(), when the value of the MultiTable is an odd number, print out Z Must use...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the number of Adult tickets to purchase Prompt user to input the number of Children tickets to purchase Prompt user to input the number of Senior tickets to purchase Write a method named, ticketCost(), which will be invoked by main() with statement similar to: cost = ticketCost( adults, children, senior ); Ticket costs structure: $15.00 for each adult $10.00 for each child $5.00 for each...
Write a C program with call to functions to produce the output given below. // the...
Write a C program with call to functions to produce the output given below. // the requirements are that there should be 5 files; intList.h, intList.c, hw3.h, hw3.c, and main.c. please only C and use Linked List. thank you. For the 5 different files, he wants it this way: 1) main.c This file just consists of the main() function, which only consists of the displayClassInfo() function call, and the runMenuHw3() function call. 2) intList.h This file would have the IntNode...
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min...
Write a Python program: The function is named validity(). It receives 2 floating point parameters, min and max, from the program that invoked it. The function asks the user to enter a float number. Using a while loop it checks whether the number is valid (between min and max, inclusive). If not valid, the while loop uses this statement to prompt for a new number: num = float (input (" Enter a number that is at least :"+ str(min) +...
Write a program named subtract.asm that does the following using LC3 assembly language: Print a prompt...
Write a program named subtract.asm that does the following using LC3 assembly language: Print a prompt "PRESS TWO KEYS: " Note that the prompt MUST LOOK EXACTLY like the above, with a colon and a space after the word KEYS with no newline. Get a two key press from the user. Subtract the second characters ASCII code from the first characters ASCII code. If the result is positive, print the word POSITIVE. Turn in subtract.asm to the appropriate submission point...
Write a program that has a function (named getNumStats()) that will return a string that has...
Write a program that has a function (named getNumStats()) that will return a string that has stats on the number entered. The prototype is: string getNumStats(double); The stats are:             Is the number an integer or a double?             The polarity (is it positive or negative; 0 counts as positive)             The parity (is it odd or even)             Is it a prime number? (for this program, 1 is considered a prime number) For example, if the following lines of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT