Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a complete C++ program that prints a hotel bill. The program shall prompt the user for some numerical values, read in those values, include

Create a complete C++ program that prints a hotel bill. The program shall prompt the user for some numerical values, read in those values, include those values when calculating results, and then print the bill on the screen. To produce the example bill, the user would enter the check-in date (the numbers 3, 14 and 2012), the room number (118), and the cost of the room (72.10). The program would then calculate the state tax, room tax, and balance due, and finally print the bill.

For this assignment, you will need the library iomanip again. Starting in the main function, declare local variables to hold values for the check-in month, check-in day, check-in year, room number, cost of the room, the state tax, the room tax, and the balance due. What you want to take time thinking about is what type of numeric values will be stored in each variable. i.e. no decimal part verse having a decimal part. For this program, you will need to make two constant variables for the state tax percent (7.75%) and room tax percent (4.00%). Use those constants in your calculations.

Below is the algorithm that can be used for this program.

Algorithm Design:

Prompt the user for the check-in month, and read in this value

Prompt the user for the check-in day, and read in this value

Prompt the user for the check-in year, and read in this value

Prompt the user for the room number, and read in this value

Prompt the user for the cost of the room, and read in this value

Calculate the state tax based on the state tax percent and the cost of the room; use the state tax percent constant in your calculations; store the result

Calculate the room tax based on the room tax percent and the cost of the room; use the room tax percent constant in your calculations; store the result

Add up the cost of the room, the state tax, and the room tax; store this result as the balance due

Use a series of cout statements to print each of the lines of the bill. Some of the information that is printed will be in character strings that are part of the program; other information will come from the contents of the local variables. Incorporate the following output manipulators in your program to properly format the bill: setw, fixed, and setprecision. For example, don't use a continuous row of blank spaces to print spaces between columns or print something on the right side of the page; use the setw manipulator instead.

After your program prints the Balance Due line at the end of the bill, it does not need to print any trailing blank lines. Below is an example bill.

image text in transcribed

Check-in Date : 3/14/2012 - - - - - - - - - - Post Date Amount - - - - - - - 3/14/2011 3/14/2011 3/14/2011 Description ----------- Room Charge State Tax Room Tax Comment ------- # 118 (7.75%) (4.00%) 3 i . 0 IN NIO . . I COOO co i Balance Due: un

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions