Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Please complete on 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.
IM GETTING AN ERROR ON Correct outputs for less than 10 rooms, Correct outputs for 10 to 19 rooms, Correct outputs for 20 to 29 rooms, and Correct outputs for 30 or more rooms. Can you please analyze the code below and fix it in order for the correct output to show accordingly in the code? Thank you!
#include
#include // For setprecision
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; // Removed extra space in the constant name
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){// Corrected syntax error
discount = DISCOUNT_10_ROOMS;
}
// Apply additional discount for booking at least three days
if (numDays >=3){
discount += ADDITIONAL_DISCOUNT; // Corrected syntax error
}
// Calculate discounted cost
double discountedCost = totalCost *(1- discount); // Corrected the calculation
// 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_2

Step: 3

blur-text-image_3

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

Question

7. One or other combination of 16.

Answered: 1 week ago