Question

In: Computer Science

Design a c++ program that calculates the amount of money a person would earn over a...

Design a c++ program that calculates the amount of money a person would earn over a period of time if his salary is one penny the first day, two pennies 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, and then show total pay at the end of the period. the output should be displayed in a dollar amount, not the number of pennies. The program must include at least one function in addition to the main function and must use the loop as well.

Solutions

Expert Solution

The c++ code for your assignment is given below. If you have any question let me know in comments.

******************************salary.cpp**********************************

#include <iostream>
#include<cmath>

using namespace std;

long total_money(int days){
long total=0;
cout<<"salary Table"<<endl;
cout<<"Day\t\tSalary"<<endl;
for(int i=0;i<days;i++){
total=total+pow(2,i);
cout<<"Day "<<i+1<<"\t\t"<<pow(2,i)<<endl;
}
return total;
  

}

int main()
{
long total=0;
double dollars;
int days;
cout<<"Enter the number of days:";
cin>>days;
total=total_money(days);
dollars=(double)total/100;
cout<<"Total money earned is: "<<dollars<<"$"<<endl;
  

return 0;
}


Related Solutions

Write a program that calculates the amount a person would earn over a period of time...
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 number of pennies. Input Validation: Do not...
make a c++ program that calculates the amount left from a value of money of one...
make a c++ program that calculates the amount left from a value of money of one dollar bill or less in quarters, dimes, nickels, and pennies. The remaining value can be shown in cents knowing that in cents: penny = 1 nickel = 5 dime = 10 quarter = 25
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed. b.Modify the program in Exercise 2a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method. c.Modify the program in Exercise 2b so that...
For C++ Download the attached program template. The programs calculates the amount of profit or loss...
For C++ Download the attached program template. The programs calculates the amount of profit or loss from a stock transaction. Using the values initialized by the program, calculate and print out the following results: "Total paid for stock" "Purchase commission " "Total received for stock" "Sales commission" "Amount of profit or loss" Use the following formulas: Total_paid = (total purchase price) + purchase_commission; Total_received = (total sales price) - sales_commission; profit = Total_received - Total_paid /* * COSC 1337 Programming...
In the space provided below write a C program that computes the total amount of money...
In the space provided below write a C program that computes the total amount of money you have stored in your piggy bank. Your program does this by asking you for number of pennies, nickels, dimes, and quarters in the piggy bank and then displays how much money in total is in the piggy bank.
In C Program #include Create a C program that calculates the gross and net pay given...
In C Program #include Create a C program that calculates the gross and net pay given a user-specified number of hours worked, at minimum wage. The program should compile without any errors or warnings (e.g., syntax errors) The program should not contain logical errors such as subtracting values when you meant to add (e.g., logical errors) The program should not crash when running (e.g., runtime errors) When you run the program, the output should look like this: Hours per Week:...
Consider the following scenario and design a C++ program using an output stream file: A person...
Consider the following scenario and design a C++ program using an output stream file: A person invests $1,000 on a savings account yielding 5% interest. Assuming that all the interest is left on deposit, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula to determine the amounts: a = p (1 + r)n where p is the original amount invested (i.e., the principal) r is the...
1) Here is a program in c++ that calculates a speeding ticket, modify the program to...
1) Here is a program in c++ that calculates a speeding ticket, modify the program to double to cost of the ticket in a construction zone. // This project will calculate a speeding ticket between 0 to 150 mph. // 1. Ask for speed. // 2. Input speed of vehicle // 3. Calculate ticket cost (50$ if over 50mph with an additional 5$ for every mph over). // 4. Display cost of ticket. #include<iostream> using namespace std; int main() {...
Modify the provided code to create a program that calculates the amount of change given to...
Modify the provided code to create a program that calculates the amount of change given to a customer based on their total. The program prompts the user to enter an item choice, quantity, and payment amount. Use three functions: • bool isValidChoice(char) – Takes the user choice as an argument, and returns true if it is a valid selection. Otherwise it returns false. • float calcTotal(int, float) – Takes the item cost and the quantity as arguments. Calculates the subtotal,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT