Write a program that calculates how much a person would earn over a period of ti
ID: 3688368 • Letter: W
Question
Write a program that calculates how much a person would earn over a period of time if his or her salary is one penny the first day and 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 how much the salary was 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 accept a number less than 1 for the number of days worked.Explanation / Answer
#include<iostream.h>
void main()
{
int salary,no_days;
cout << "enter no of days";
cin >> no_days;
if (no_days <1)
exit(0);
cout << "enter the salary:";
cin >> salary;
int result=salary(no_days(no_days+1)/2);
cout << "total earned:" << result << endl;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.