Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 con­tinues 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;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote