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 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 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 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 C++ program using functions (separate function for each bottom) Write a program to find if...
write C++ program using functions (separate function for each bottom) Write a program to find if a number is large word for two given bottom base - bottom1 and bottom2. You can predict that a number, when converted to any given base shall not exceed 10 digits. . the program should ask from user to enter a number that it should ask to enter the base ranging from 2 to 16 after that it should check if the number is...
Create a function named getCreds with no parameters that will prompt the user for their username...
Create a function named getCreds with no parameters that will prompt the user for their username and password. This function should return a dictionary called userInfo that looks like the dictionaries below: # Administrator accounts list adminList = [ { "username": "DaBigBoss", "password": "DaBest" }, { "username": "root", "password": "toor" } ] Create a function named checkLogin with two parameters: the userInfo and the adminList. The function should check the credentials to see if they are contained within the admin...
JAVA Program 2: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt...
JAVA Program 2: In Order Using an IF/ELSE IF/ELSE structure, write a program that will prompt the user for three numbers and displays them in ascending order. First, the program will prompt the user for each of the three numbers. Next, find the smallest value of the three. Then decide which of the other two is the next smallest. Then have the program display the three numbers in ascending order. Be sure to do the following: Determine what the input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT