Project 3
Objective:
The purpose of this lab project is to exposes you to using menus, selection writing precise functions and working with project leaders.
Problem Specification:
The PCCC Palace Hotel needs a program to compute and prints a statement of charges for customers.
The software designer provided you with the included C++ source and you are asked to complete the code to make a working program using the given logic. The function main () should not change at all.
Given Information:
Your input to the program consists of the customer’s name, room number, and the number of days they stayed in the hotel.
A sample input for the program would be:
The customer name please: Eddie
Room Number: 318
Number of days stayed in the Hotel: 3
Room Requirements:
This is a multi-level hotel where the room number ending with
20-39 are Family rooms
40-50 are Suites.
Rooms ending with a number > 50 are an error because they don’t exist.
Room Rates are defined as local constants and are for each day as follows:
Internet Access Requirements:
a prompt to see if there was internet access such as:
Internet Accessed (Y/N): Y
options are chosen from menus to handle each of the inputs
A sample input if there was access would be:
Access
1 - Wired
2 – Not-wired (Wireless)
Enter Choice 1 or 2 : 1 (note that input may be 1, W, w, 2, N, or n)
Internet Access rates are defined as local constants and are for each day as follows:
TV Access Requirements:
A prompt to see if there was TV access such as:
TV Used (Y/N): Y
options are chosen from menus to handle each of the inputs
A sample input if there was access would be:
TV Usage
1 - Basic Channels
2 – Cable Channels
Enter Choice 1 or 2 : b (note that input may be 1, B, b, 2, C, or c)
TV Access are defined as local constants and are for each day as follows:
Complete the application based on the given source code to allow you to enter the information above, and prints a statement of the charges to be given to the customer when they checkout. Do not change the logic in the given source.
A sample output statement would be:
PCCC Palace Hotel
Room Number: 318
Eddie’s Billing Statement
Number of days in hotel: 3 in a Single Room
Room Charges $299.97
Internet Charges (Wireless) $17.85
Television Charges (Basic) $5.85
Total Charges $323.67
Local Taxes $45.55
Total Due $469.22
Thank you for using PCCC Palace Hotel. Hope to see you again.
Note: the above statement, report, does not reflect correct calculations.
Requirements:
Grading criteria:
5 points |
Your name, Date, course #, Due Date, name of the program and explanation to what the program does. |
5 points |
All constants are defined locally, used correctly and properly. |
5 points |
Appropriate and descriptive identifier names are used. |
5 points |
Menus are used to allow selection for each of the charge items. |
5 points |
iomanip features are used to format and money is printed with $ and 2 decimal spaces. |
5 points |
A prompt is used for Internet access and TV use. |
15 points |
IF statements are used properly and are clear. |
5 points |
An error message is printed if room number is > 50 and program is exited. |
5 points |
Specifications, Comments explaining every function are placed above each functions definition. |
5 points |
Functions are used clearly and properly to calculate each of the charged items. |
5 points |
Each function returns the charges to main (). |
5 points |
Proper headings and footings are displayed. |
5 points |
Invoice appearance is clear and looks nice. |
10 points |
Flowchart for every function, in full details, is handed-in and is correct. no pseudo-code. |
10 points |
Program runs correctly and performs the specified task. |
5 points |
Multiple test runs showing evidence of all requirements are submitted. |
Given Source :
#include <iostream> #include <cctype> #include <cstdlib> using namespace std; int main() { string name; string roomtype, nettype, tvtype; int days,roomnumber; float roomcharges,netcharges,tvcharges; setinfo(name,roomnumber,days); roomcharges = setroom(roomnumber, days,roomtype); netcharges = setnet(days,nettype); tvcharges = settv(days,tvtype); getinfo(name, days,roomcharges,netcharges,tvcharges,roomtype,nettype,tvtype); return 0; }
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
using namespace std;
// Function to accept customer name room number and number of
days staying
void setinfo(string &name, int &roomnumber, int
&days)
{
// Accepts customer name
cout<<"\n The customer name please: ";
cin>>name;
// Loop till valid room number entered by the user
do
{
// Displays room number with room type and price
cout<<"\n 300 - 319 for Single room Single bed $99.99"
<<"\n 320 - 339 for Family room double bed $149.99"
<<"\n 340 - 349 for Suite $199.99";
// Accepts room number
cout<<"\n Room Number: ";
cin>>roomnumber;
// Checks if room number is between 300 and 349 inclusive
// then come out of the loop (valid room number)
if(roomnumber >= 300 && roomnumber <= 349)
break;
// Otherwise invalid room number
// Displays message and continue the loop
else
cout<<"\n Invalid room number. Try again.";
}while(1);// End of do while loop
// Accepts number of days
cout<<"\n Number of days stayed in the Hotel: ";
cin>>days;
}// End of function
// Function to set room type using call by reference
// Calculates and returns room charges
float setroom(int roomnumber, int days, string &roomtype)
{
// To store room charges
float charges;
// Checks if room number is between 300 and 319 inclusive
if(roomnumber >= 300 && roomnumber <= 319)
{
// Set the room type
roomtype = " in a Single Room.";
// Calculates room charges based on number of days
charges = days * 99.99f;
}// End of if condition
// Otherwise checks if room number is between 320 and 339
inclusive
else if(roomnumber >= 320 && roomnumber <= 339)
{
// Set the room type
roomtype = " in a Family room.";
// Calculates room charges based on number of days
charges = days * 149.99f;
}// End of else if condition
// Otherwise room number is between 340 and 349 inclusive
else
{
// Set the room type
roomtype = " in a Suite.";
// Calculates room charges based on number of days
charges = days * 199.99f;
}// End of else
// Returns room charges
return charges;
}// End of function
// Function to set net type using call by reference
// Calculates and returns net charges
float setnet(int days, string &nettype)
{
// To store user choice 'Y' or 'N'
char ch;
// To store accept type menu option number
int ac;
// To store Internet charges
float charges;
cout<<"\n Internet Access Requirements: ";
// Loops till user choice is not 'Y' or 'y' or 'N' or 'n'
do
{
// Accepts user choice
cout<<"\n Internet Accessed (Y/N): ";
cin>>ch;
// Checks if user choice is 'Y' or 'y'
if(ch == 'Y' || ch == 'y')
{
// Displays access menu
cout<<"\n Access \n 1 - Wired \n 2 - Not-wired (Wireless):
";
// Accepts access choice
cin>>ac;
// Checks if access choice is 1
if(ac == 1)
{
// Sets the net type
nettype = "Wired";
// Calculates net charges based on number of days
charges = days * 3.95f;
}// End of if condition
// Otherwise access choice is 2
else
{
// Sets the net type
nettype = "Wireless";
// Calculates net charges based on number of days
charges = days * 5.95f;
}// End of else
}// End of outer if condition
// Otherwise checks if user choice is 'N' or 'n'
else if(ch == 'N' || ch == 'n')
{
// Sets the net type not no access
nettype = "No Internet";
// Sets the charges to 0
charges = 0.0f;
}// End of else if condition
// Otherwise invalid choice continue (not y or n)
else
cout<<"\n Invalid choice! Try again.";
// Checks if user choice is either y or n in any case then
break
if(ch == 'Y' || ch == 'y' || ch == 'N' || ch == 'n')
break;
}while(1);// End of do while loop
// Returns Internet charges
return charges;
}// End of function
// Function to set tv type using call by reference
// Calculates and returns tv charges
float settv(int days, string &tvtype)
{
// To store user choice 'Y' or 'N'
char ch;
// To store channel type menu option number
int tv;
// To store tv charges
float charges;
cout<<"\n TV Access Requirements: ";
// Loops till user choice is not 'Y' or 'y' or 'N' or 'n'
do
{
// Accepts user choice
cout<<"\n TV Used (Y/N): ";
cin>>ch;
// Checks if user choice is 'Y' or 'y'
if(ch == 'Y' || ch == 'y')
{
// Displays channel menu
cout<<"\n TV Usage \n 1 - Basic Channels \n 2 - Cable
Channels: ";
// Accepts channel choice
cin>>tv;
// Checks if channel choice is 1
if(tv == 1)
{
// Sets the channel type
tvtype = "Basic channels";
// Calculates channel charges based on number of days
charges = days * 1.95f;
}// End of if condition
// Otherwise channel choice is 2
else
{
// Sets the channel type
tvtype = "Cable Channels";
// Calculates channel charges based on number of days
charges = days * 4.95f;
}// End of else
}// End of outer if condition
// Otherwise checks if user choice is 'N' or 'n'
else if(ch == 'N' || ch == 'n')
{
// Sets the channel no
tvtype = "No TV Access";
// Sets the channel charges to 0
charges = 0.0f;
}// End of else if condition
// Otherwise invalid choice continue (not y or n)
else
cout<<"\n Invalid choice! Try again.";
// Checks if user choice is either y or n in any case then
break
if(ch == 'Y' || ch == 'y' || ch == 'N' || ch == 'n')
break;
}while(1);// End of do while loop
// Returns tv charges
return charges;
}// End of function
// Function to calculate total charges, local tax and total
due
// Displays bill
void getinfo(string name, int days, int roomnumber, float
roomcharges, float netcharges, float tvcharges,
string roomtype, string nettype, string tvtype)
{
// To store total charges, local tax and total due
float totalCharges, localTax, totalDue;
// Calculates total charges
totalCharges = (roomcharges + netcharges + tvcharges);
// Calculates local tax 15% of total charges
localTax = totalCharges * .15f;
// Calculates total due including local tax
totalDue = totalCharges + localTax;
// Displays information
cout<<"\n PCCC Palace Hotel";
cout<<"\n Room Number: "<<roomnumber;
cout<<"\n\n Eddie's Billing Statement";
cout<<"\n Number of days in hotel:
"<<days<<roomtype;
cout<<"\n Room Charges
$"<<fixed<<setprecision(2)<<roomcharges;
cout<<"\n Internet Charges ("<<nettype<<")
$"<<netcharges;
cout<<"\n Television Charges ("<<tvtype<<")
$"<<tvcharges;
cout<<"\n Total Charges $"<<totalCharges;
cout<<"\n Local Taxes $"<<localTax;
cout<<"\n Total Due $"<<totalDue;
}// End of function
// main function definition
int main()
{
// To store customer name
string name;
// To store room type, net type and tv type
string roomtype, nettype, tvtype;
// To store number of days staying and room number
int days,roomnumber;
// To store room charges, net charges and tv charges
float roomcharges, netcharges, tvcharges;
// Calls the function to accept user information
setinfo(name, roomnumber, days);
// Calls the function to set room type and stores return value
as room charges
roomcharges = setroom(roomnumber, days,roomtype);
// Calls the function to set net type and stores return value as
net charges
netcharges = setnet(days,nettype);
// Calls the function to set tv type and stores return value as
tv charges
tvcharges = settv(days,tvtype);
// Calls the function to display bill
getinfo(name, days, roomnumber, roomcharges, netcharges, tvcharges,
roomtype, nettype, tvtype);
return 0;
}// End of main function
Sample Output:
The customer name please: Pyari
300 - 319 for Single room Single bed $99.99
320 - 339 for Family room double bed $149.99
340 - 349 for Suite $199.99
Room Number: 620
Invalid room number. Try again.
300 - 319 for Single room Single bed $99.99
320 - 339 for Family room double bed $149.99
340 - 349 for Suite $199.99
Room Number: 210
Invalid room number. Try again.
300 - 319 for Single room Single bed $99.99
320 - 339 for Family room double bed $149.99
340 - 349 for Suite $199.99
Room Number: 318
Number of days stayed in the Hotel: 3
Internet Access Requirements:
Internet Accessed (Y/N): p
Invalid choice! Try again.
Internet Accessed (Y/N): y
Access
1 - Wired
2 - Not-wired (Wireless): 2
TV Access Requirements:
TV Used (Y/N): s
Invalid choice! Try again.
TV Used (Y/N): Y
TV Usage
1 - Basic Channels
2 - Cable Channels: 1
PCCC Palace Hotel
Room Number: 318
Eddie's Billing Statement
Number of days in hotel: 3 in a Single Room.
Room Charges $299.97
Internet Charges (Wireless) $17.85
Television Charges (Basic channels) $5.85
Total Charges $323.67
Local Taxes $48.55
Total Due $372.22
Project 3 Objective: The purpose of this lab project is to exposes you to using menus,...
Course Project 1.You are going to research two local hotels. You will need to call or visit the two properties. In addition make sure you research the hotels website and find the response to the following questions in detail: a. What is the rack rate for a “standard” room? b. What is included in this rate? c. What amenities are offered at their property – pool ,restaurant etc.? d. Are rates different on the weekend? Higher or Lower? e. What...
The objective of this project is to provide experience working with user interface menus and programmed decision making. Modify the C++ source you created in Project # 2 to incorporate the following requirements: 1. Present a menu to the user which includes: a. Enter checking account transaction b. Enter savings account transaction c. Quit 2. If the user selects a., request the checking account balance, the checking account transaction date, the checking account description, and the checking account amount from...
There are a sotall of five classes and one enum required for this project. Over the course of the projeet, it is important that you pay attention to how different responsibilities are separaled between the classes and how they work in coejuncticn to handle a probiem A quick list of the necessary items for this peogram are HotelManagement Class This is the driver class foe your peogram It will cntain a methed for setting up an initial hotel and the...
Project: Using Java API Classes Page 3 of 5 SpaceTicket.java Requirements: The purpose of this program is accept coded space ticket information as input that includes the ticket price, category, time, date, and seat, followed by the description of the travel. Note that the eight digits for price have an implied decimal point. The program should then print the ticket information including the actual cost, which is the price with discount applied as appropriate: 25% for a student ticket (s),...
The purpose of this project is to give students more exposure to object oriented design and programming using classes and polymorphism in a realistic application that involves arrays of objects and sorting arrays containing objects A large veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month the vet requests and updates listing of all pets sorted by their "outstanding...
Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will use the concept of object aggregation (i.e., has-a relationship between objects). You will implement a Java application, called MovieApplication that could be used in the movie industry. You are asked to implement three classes: Movie, Distributor, and MovieDriver. Each of these classes is described below. Problem Description The Movie class represents a movie and has the following attributes: name (of type String), directorName...
Propose: In this lab, you will complete a Python program with one partner. This lab will help you with the practice modularizing a Python program. Instructions (Ask for guidance if necessary): To speed up the process, follow these steps. Download the ###_###lastnamelab4.py onto your desktop (use your class codes for ### and your last name) Launch Pyscripter and open the .py file from within Pyscripter. The code is already included in a form without any functions. Look it over carefully....
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...
In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...
In this project you will write a C++ program that simulates the purchase of a single item in an online store. What to do Write a C++ program that: 1. Prints out a welcome message. 2. Prompts the user for the following information: (a) Their first name (example: Roger) (b) Their last name (example: Waters) (c) The name of the product (example: Brick) (d) The unit price of the product (example: 1.99) (e) The quantity to buy (example: 200) (f)...