Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete using c + + The cost of renting a room at a hotel is , say $ 1 0 0 . 0 0

Please complete using c++
The cost of renting a room at a hotel is, say $100.00 per night. For special occasions, such as a wedding or conference, the hotel offers a special discount as follows: If the number of rooms booked is at least 10, the discount is 10%; at least 20, the discount is 20%; and at least 30, the discount is 30%. Also if rooms are booked for at least three days, then there is an additional 5% discount. Write a program that prompts the user to enter the cost of renting one room, the number of rooms booked, the number of days the rooms are booked, and the sales tax (as a percent). The program outputs the cost of renting one room, the discount on each room as a percent, the number of rooms booked, the number of days the rooms are booked, the total cost of the rooms, the sales tax, and the total billing amount. Your program must use appropriate named constants to store special values such as various discounts.
Here is my code but i'm failing on correct output for less than 10 rooms, 10-19,20-29, and 3o or more rooms. Please look over the code to see where my mistakes are.
#include
#include
using namespace std;
// Constants for discounts and sales tax
const double DISCOUNT_10_ROOMS =0.10;
const double DISCOUNT_20_ROOMS =0.20;
const double DISCOUNT_30_ROOMS =0.30;
const double ADDITIONAL_DISCOUNT =0.05;
int main(){
// Variables to store user input
double roomCost, salesTax;
int numRooms, numDays;
// Prompt user for input
cout << "Enter the cost of renting one room: $";
cin >> roomCost;
cout << "Enter the number of rooms booked: ";
cin >> numRooms;
cout << "Enter the number of days the rooms are booked: ";
cin >> numDays;
cout << "Enter the sales tax rate (as a percent): ";
cin >> salesTax;
// Calculate total cost without considering discounts
double totalCost = roomCost * numRooms * numDays;
// Apply discounts based on the number of rooms booked
double discount =0.0;
if (numRooms >=30){
discount = DISCOUNT_30_ROOMS;
} else if (numRooms >=20){
discount = DISCOUNT_20_ROOMS;
} else if (numRooms >=10){
discount = DISCOUNT_10_ROOMS;
}
// Apply additional discount for booking at least three days
if (numDays >=3){
discount += ADDITIONAL_DISCOUNT;
}
// Calculate discounted cost
double discountedCost = totalCost -(totalCost * discount);
// Calculate sales tax amount
double taxAmount = discountedCost *(salesTax /100.0);
// Calculate total billing amount
double totalAmount = discountedCost + taxAmount;
// Output results
cout << fixed << setprecision(2);
cout <<"
Cost of renting one room: $"<< roomCost << endl;
cout << "Discount on each room: "<< discount *100<<"%"<< endl;
cout << "Number of rooms booked: "<< numRooms << endl;
cout << "Number of days the rooms are booked: "<< numDays << endl;
cout << "Total cost of the rooms: $"<< totalCost << endl;
cout << "Sales tax: "<< salesTax <<"%"<< endl;
cout << "Total billing amount: $"<< totalAmount << endl;
return 0;
}

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions