Question

In: Computer Science

C++ in one program that ends with return 0} at the end f Write a program...

C++

in one program that ends with return 0} at the end f


Write a program to calculate the salary paid to its salespersons at Pohanka. The salary is calculated based on a salesperson’s length of employment in years and employment category (full-time employee or part-time employee). The salary calculation rules are as following: 1) If an employee is a part-time employee and worked here for less than 5 years, the salary consists of only the commission amount; 2) If an employee is a part-time employee and worked here for more than or equal to 5 years, the salary consists of base salary of $2,500 and commission amount; 3) If an employee is a full-time employee and worked here for less than 5 years, the salary consists of base salary of $5,000 and commission amount; 4) If an employee is a full-time employee and worked here for more than or equal to 5 years, the salary consists of base salary of $10,000 and commission amount. The commission amount is calculated using the following commission rates: Sales Amount Commission Rate $0 to $15,000 10% $15,001 to $60,000 15% Over $60,000 33% But there is a catch. The sales amount between $15,001 to $60,000 gets only 10% on the first $15,000 and 15% on the remaining. The sales amount above $60,000 pays only 10% on the first $15,000 and 15% on the next $45,000 and 33% on the remaining amount  


Solutions

Expert Solution

C++ Program:

#include <iostream>

using namespace std;

double commision(double sales_amount)
{
    double first_15 = 15000, next_45 = 45000, rest, commision_amount = 0;
    if (sales_amount > 60000)
    {
        rest = sales_amount - (first_15 + next_45);
        first_15 = ( first_15 * 10 ) / 100;
        next_45 = ( next_45 * 15) / 100;
        rest = (rest * 33) / 100;
        commision_amount = first_15 + next_45 + rest;
    }
    else if ((sales_amount >= 15001) && (sales_amount <= 60000))
    {
        rest = sales_amount - first_15;
        first_15 = ( first_15 * 10 ) / 100;
        rest = (rest * 15) / 100;
        commision_amount = first_15 + rest;
    }
    else if ((sales_amount >= 0) && (sales_amount <= 15000))
    {
        sales_amount = (sales_amount * 10) / 100;
        commision_amount = sales_amount;
    }
    return commision_amount;
}

int main()
{
    cout<<"1. Part-Time Employee \n2. Full-Time Employee";
    int type, years;
    double sales_amount, base_salary = 0, salary = 0;
    cout<<"\n\n-----------------------------------------";
    cout<<"\nEnter Employee Type: ";
    cin>>type;
    cout<<"Enter Years of Employment: ";
    cin>>years;
    cout<<"Enter Your Sales Amount: ";
    cin>>sales_amount;
    cout<<"-----------------------------------------";
    
    switch(type)
    {
        case 1:
            if (years < 5)
            {
                salary = commision(sales_amount);
                cout << "\n\n************** SALARY SLIP **************";
                cout << "\n\nYour Salary: " << salary;
                cout << "\n\n*****************************************";
            }
            else if (years >= 5)
            {
                base_salary = 2500;
                salary = base_salary + commision(sales_amount);
                cout << "\n\n************** SALARY SLIP **************";
                cout << "\n\nYour Salary: " << salary;
                cout << "\n\n*****************************************";
            }
            break;
        case 2:
            if (years < 5)
            {
                base_salary = 5000;
                salary = base_salary + commision(sales_amount);
                cout << "\n\n************** SALARY SLIP **************";
                cout << "\n\nYour Salary: " << salary;
                cout << "\n\n*****************************************";
            }
            else if (years >= 5)
            {
                base_salary = 10000;
                salary = base_salary + commision(sales_amount);
                cout << "\n\n************** SALARY SLIP **************";
                cout << "\n\nYour Salary: " << salary;
                cout << "\n\n*****************************************";
            }
            break;
        
        default:
            cout << "Wrong Entry of Type of Employement !!, Try Again !!";
    }

    return 0;
}

Output:

Thumbs Up Please !!!


Related Solutions

Write a program using C to read a list of your friend names which ends by...
Write a program using C to read a list of your friend names which ends by the word end. The program builds a linked list using these names and prints the names in the order stored into the linked list The list can be created using insertion at the beginning or insertion at the end; Use switch case to select the type of insertion; Case 1:insertion in the beginning; Case2:insertion in the end. Once the list is printed after insertion;...
Using C++ Write One one single program with two or more functioncallsWrite a C++...
Using C++ Write One one single program with two or more function callsWrite a C++ function, smallest Index, that takes as parameters an int array and its size and returns the index of the smallest element in the array. Also the program should test the function.Write another function that prompts the user to input a string and outputs the string in uppercase letters. You must use a character array to store the string.
C++ Write a program that lets the user enter a two letters which are f and...
C++ Write a program that lets the user enter a two letters which are f and s with a length of 5. And outputs how many times it was occurred and lists the 2 most repeating pattern with 5lengths of f and s. The output display should always start at three-f(s) .Include an option where user can retry the program. Example: Input: sssfsfsfssssfffsfsssssfffsffffsfsfssffffsfsfsfssssfffffsffffffffffffssssssssfffsffffsssfsfsfsfssssfffsssfsfsffffffssssssffffsssfsfsfsss Output: The most repeating 5lengths of pattern is: fffsf and occurred 6times. Output2: The second most repeating...
Write a C++ program to read a collective of integer numbers. I f the number is...
Write a C++ program to read a collective of integer numbers. I f the number is greater than zero and less than 15 then terminate the loop and find factorial of the number
Write a C# program to ask the user for an undetermined amount ofnumbers (until 0...
Write a C# program to ask the user for an undetermined amount of numbers (until 0 is entered) and display their sum.
C programming. Write a program that prompts the user to enter a 6x6 array with 0...
C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.
Write a C++ program that inputs the world's population at the end of last year. Assume...
Write a C++ program that inputs the world's population at the end of last year. Assume population is growing at a rate of 1.12%. Output the year (starting with this year) and the population until the population is greater than 10billion. Test data: 6.83 billion. (leave like this rather than 6800000000). Name as a comment and printed to output. Output as a comment at the bottom of the code
Write a small C++ program with 4 functions (and main(): getNumbers()- what is the return, what...
Write a small C++ program with 4 functions (and main(): getNumbers()- what is the return, what are the parameters? findMax()- what is the return, what are the parameters? findMin()-what is the return, what are the parameters? find()- should return the index of the element or a -1 indicating not found The main function will call those methods and print the results of each. 1 // declare necessary variables 2 // declare array 3 double numbers[SIZE]; 4 // Function prototypes 5...
a b c d f 0 0 0 0 0 0 0 0 1 0 0...
a b c d f 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1...
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT