Question

Show Me The Money. (15 points) Write a C++ program that calculates how much a person earns in a month if the salary is one pe

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<bits/stdc++.h> 
using namespace std;

int main() {
    int days;
    int ch=1;
    char retry;
        do{
        cout<<"How many days did the employee work this month? ";   
        cin>>days;
        while(1){
            if(days<1 || days>31){
                cout<<"The number of days must be between 1 and 31."<<endl;
                cout<<"Please re-enter days worked: ";
                cin>>days;
            }
            else
                break;
        }
        
        double start = 0.01;
        double sum =0; 
        cout<<"Day"<<"\t\t"<<"Pay"<<endl;
        cout<<"----------------------"<<endl;
        for(int i=1;i<=days;i++){
            cout<<i<<"\t\t"<< fixed << setprecision(2)<<start<<endl;
            sum+=start;
            start = start*2;
        }
        cout<<"----------------------"<<endl;
        cout<<"Total $"<<" \t "<< fixed << setprecision(2)<<sum<<endl;
        cout<<"Do you want to try again? (Y or N) ";
        cin>>retry;
        if(retry=='Y' || retry=='y')
            ch=1;
        else
            ch=0;
        }while(ch);
        
        return 0;
}

NOTE: The above code is in C++. Please refer to the attached screenshots for code indentation and sample I/O.

do{ 1 #include<bits/stdc++.h> 2 using namespace std; 3 4- int main() { 5 int days; 6 int ch=1; 7 char retry: 8- 9 cout<<How

SAMPLE I/O:

How many days did the employee work this month? 3 Day Pay 0.01 2 0.02 3 0.04 Total $ 0.07 Do you want to try again? (Y or N)

Add a comment
Know the answer?
Add Answer to:
Show Me The Money. (15 points) Write a C++ program that calculates how much a person...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Week 5 Project Write a program that calculates the amount of money a person would earn...

    Week 5 Project Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, four pennies the third day, and continues to double each day. Output the amount earned each day .. and the total pay at the end. The Algorithm (Plan) for your program would be: Ask the user for the number of days to be...

  • Write a Java program that calculates how much a person would earn after a period of...

    Write a Java program that calculates how much a person would earn after a period of time, according to the following rules: 1. The starting salary for the first day is $1. 2. The salary will double each day. Ask the user to input the number of days worked. The output should display how much the salary was for each day worked, and show the total pay at the end of the work period. Get output similar to the sample...

  • Write a program using Python that calculates the amount of money a person would earn over...

    Write a program using Python that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed...

  • HTML only Design and implement a program that calculates the amount of money a person would...

    HTML only Design and implement a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should:ask the user for the number of daysdisplay a table showing what the salary was for each daythen show the total pay at the end of the period.The output should be displayed in the...

  • In Java. Use the concept of LOOPS: 2.Write a program that calculates the amount a person...

    In Java. Use the concept of LOOPS: 2.Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the...

  • Write a program that calculates the amount a person would earn over a 30-day period of...

    Write a program that calculates the amount a person would earn over a 30-day period of time if his/her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. A sample output might look...

  • In Python. Write a program that will calculate the amount of money a person would earn...

    In Python. Write a program that will calculate the amount of money a person would earn over a period of time if his/her salary is one penny the first day and two pennies for the second day, and continue to double each day. Hints: Declare variables Get the number of days from the user. Show the salary table for each day 4. Use ‘for loop’ to loop through the range of days (1, num_days +1) 5. Display the total pay...

  • <!DOCTYPE html> <html> <body> <script> // // Write a function that calculates the amount of money...

    <!DOCTYPE html> <html> <body> <script> // // Write a function that calculates the amount of money a person would earn over // a period of years if his or her salary is one penny the first day, two pennies // the second day, and continues to double each day. The program should ask the // user for the number of years and call the function which will return the total // money earned in dollars and cents, not pennies. Assume...

  • C++ Linked Lists You have been hired by Employees. Inc to write an employee management system....

    C++ Linked Lists You have been hired by Employees. Inc to write an employee management system. The following are your specifications: Write a program that uses the following linked lists: bullet empId: a linked list of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489 bullet hours: a linked list of seven integers to hold the number of hours worked by each employee bullet payRate:...

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT