Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a c++ program Write a program that calculates how much a person would earn over a period of time if his or her

Please write a c++ program
image text in transcribed
image text in transcribed
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, two pennies the second day, and continues to double each day. The program should proceed as follows: Ask the user for the number of days worked, and allow them to enter it. You may assume this will be an integer A valid entry must be 1 or more days, so whenever the user enters a valid that is not positive (1 or more), print an error message and make them re-enter until they give a valid value. Display a table showing how much the salary was for each day. You can use the \t character to help print neat columns Display the total pay at the end of the period All monetary outputs should be in dollar and cents notation (not just number of pennies), in this format: $ D.cc, where D is the number of dollars, and cc is the cents (always two digits). Examples: Valid: $ 1.34 . $ 0.05, $ 123.45 Sample Run 1 Please enter the number of days worked: -1 Invalid number of days. Try again Please enter the number of days worked: O Invalid number of days. Try again Please enter the number of days worked: 5 Day Amount Earned $ 0.01 $ 0.02 $ 0.04 $ 0.08 $ 0.16 Total earnings: $ 0.31 Sample Run 2 Please enter the number of days worked: 18 Day Amount Earned $ 0.01 $ 0.02 $ 0.04 $ 0.08 $ 0.16 $ 0.32 $ 0.64 $ 1.28 $ 2.56 $ 5.12 $ 10.24 $ 20.48 $ 40.96 $81.92 $ 163.84 $ 327.68 $ 655.36 $ 1310.72 Total earnings: $ 2621. 43

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Explain knurling.i am not satisfy give downvote

Answered: 1 week ago