Needs to be coded in c, main needs to take command line arguments, thus: int main(int argc, char*argv[])
it will take three files, htls.dat, roms.dat, cst.dat
htls.dat
4
Hilton
BstWestern
HolmesEstates
MoriarityInn
roms.dat
5
Standard
Queen
King
Suite
Presidential
cst.dat
50 75 120 145 200
75 125 155 200 355
145 175 250 350 400
300 400 500 600 900
needs to have following functions:
const char *const GetHotelName(int hotel) - returns string from hotelnames global variable
const char*const GetRoomName(int room) - returns string from roomnames global variable
void PrintHotelOptions() - prints list of hotels
void PrintRoomOptions() - prints list of rooms
void PrintHotelRoomsLessThan(int iLimit) - prints hotels and prices
int getMainMenuChoice() - Displays menu and returns user's selection
int GetRoomPrice(int hotel, int room) - returns price of a fiven room in a given hotel
void printHotelsByRoom(int room) - prints list of hotels and prices for given room type
int LoadHtelNames(char *sFileName) - loads hotel name from .dat into memory
int LoadRomNames(char *sFileName) - loads room name from .dat into memory
int LoadCstMatrix(char *sFileName) - loads cost matrix from .dat into memory
void PrintCostMatrix() - prints out cost matrix to screen
void PrintHotelNames() - prints hotel name list to screen
void printRoomNames() - prints room type list to screen
OUTPUT:
Hotel Names:
Hilton
BstWestern
HolmesEstates
MoriarityInn
Room Names:
Standard
Queen
King
Suite
Penthouse
CostMatrix:
Hilton, Standard = 50
Hilton, Queen = 75
Hilton, King = 120
Hilton, Suite = 145
Hilton, Penthouse = 200
BstWestern, Standard = 75
BstWestern, Queen = 125
BstWestern, King = 155
BstWestern, Suite = 200
BstWestern, Penthouse = 355
HolmesEstates, Standard = 145
HolmesEstates, Queen = 175
HolmesEstates, King = 250
HolmesEstates, Suite = 350
HolmesEstates, Penthouse = 400
MoriarityInn, Standard = 300
MoriarityInn, Queen = 400
MoriarityInn, King = 500
MoriarityInn, Suite = 600
MoriarityInn, Penthouse = 900
Data Complete!
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection: 1
1. Hiltont
2. BstWestern
3. HolmesEstates
4. MoriarityInn
Select a hotel: 3
*** Rooms at HolmesEstates:
HolmesEstates - Standard ($145)
HolmesEstates - Queen ($175)
HolmesEstates - King ($250)
HolmesEstates - Suite (350)
Holmes Estates - Penthouse($400)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection: 2
1. Standard
2. Queen
3. King
4. Suite
5. Penthouse
Select a room: 2
*** Hotels with room Queen:
Hilton - Queen ($75)
BstWestern - Queen ($125)
HolmesEstates - Queen ($175)
MoriarityInn - Queen ($400)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection: 3
Enter the maximum price in dollars you will pay: 100
*** Rooms less than $125:
Hilton - Standard ($50)
Hilton - Queen ($75)
BstWestern - Standard ($75)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection: 4
Goodbye!
Screenshot
-------------------------------------------------
Program
//Header files
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
//Constants
char **hotels;
char **rooms;
int **price;
int hotelsSz, roomsSz;
//Function prototype
void readFile(char *argv[]);
int mainMenu();
void hotelDetails();
void roomDetails();
void priceBySelection();
int main(int argc, char*argv[])
{
int opt;
//Argument check
if (argc < 4) {
printf("Not enough file
names!!\n");
exit(0);
}
//Read file
readFile(argv);
//Get menu
opt = mainMenu();
//Loop unti exit
while (opt != 4) {
//Each options
if (opt == 1) {
hotelDetails();
}
else if (opt == 2) {
roomDetails();
}
else if(opt==3)
{
priceBySelection();
}
opt = mainMenu();
}
//End of the program
printf("GOODBYE!\n");
}
//Read file data
void readFile(char *argv[]) {
FILE *fptr;
char names[50];
int col = 50,i;
fptr = fopen(argv[1], "r");
fscanf(fptr, "%d", &hotelsSz);
hotels = (char **)malloc(hotelsSz * sizeof(char
*));
for (i = 0; i < hotelsSz; i++)
hotels[i] = (char *)malloc(col *
sizeof(char));
i = 0;
while (fscanf(fptr, "%s", hotels[i]) == 1) {
i++;
}
fclose(fptr);
fptr = fopen(argv[2], "r");
fscanf(fptr, "%d", &roomsSz);
rooms = (char **)malloc(roomsSz * sizeof(char
*));
for (i = 0; i < roomsSz; i++)
rooms[i] = (char *)malloc(col *
sizeof(char));
i = 0;
while (fscanf(fptr, "%s", rooms[i]) == 1) {
i++;
}
fclose(fptr);
fptr = fopen(argv[3], "r");
price = (int **)malloc(hotelsSz * sizeof(int
*));
for (i = 0; i < hotelsSz; i++)
price[i] = (int *)malloc(roomsSz *
sizeof(int));
i = 0;
while (fscanf(fptr, "%d %d %d %d %d\n",
&price[i][0], &price[i][1], &price[i][2],
&price[i][3], &price[i][4]) && !feof(fptr)) {
i++;
}
fclose(fptr);
}
//Get main menu details
int mainMenu() {
int opt;
printf("*** Main Menu ***\n");
printf("1. Display by hotel\n");
printf("2. Display by room type\n");
printf("3. Display by price limit\n");
printf("4. Exit program\n");
printf("Please make a selection:");
scanf("%d", &opt);
while (opt<1 || opt>4) {
printf("Wrong option!!!\n");
printf("*** Main Menu
***\n");
printf("1. Display by
hotel\n");
printf("2. Display by room
type\n");
printf("3. Display by price
limit\n");
printf("4. Exit program\n");
printf("Please make a
selection:");
scanf("%d", &opt);
}
return opt;
}
//Option1 working
void hotelDetails() {
int i, j,opt,k=0;
for (i = 0; i < hotelsSz; i++) {
printf("%d %s\n",(i+1),
hotels[i]);
}
printf("Select a hotel:");
scanf("%d", &opt);
printf("*** Rooms at %s%c\n", hotels[opt -
1],':');
for (j = 0; j < roomsSz; j++) {
printf("%s%c%s%c%c%d%c\n",
hotels[opt - 1], '-', rooms[j], '(', '$', price[opt - 1][k],
')');
k++;
}
}
//Opt==2
void roomDetails() {
int i, j, opt, k = 0;
for (i = 0; i < roomsSz; i++) {
printf("%d %s\n", (i + 1),
rooms[i]);
}
printf("Select a room:");
scanf("%d", &opt);
printf("*** Hotels with room %s%s\n", rooms[opt -
1],"::");
for (j = 0; j < hotelsSz; j++) {
printf("%s%c%s%c%c%d%c\n",
hotels[j], '-', rooms[opt-1], '(', '$', price[j][opt-1],
')');
}
}
//opt==3
void priceBySelection() {
int cost = 0,i,j,k=0;
printf("Enter the maximum price in dollars you will
pay: ");
scanf("%d", &cost);
printf("*** Rooms less than $%d:\n", cost);
for (i = 0; i < hotelsSz; i++) {
for (j = 0; j < roomsSz; j++)
{
if (price[i][k] <= cost) {
printf("%s%c%s%c%c%d%c\n",
hotels[i], '-', rooms[j], '(', '$', price[i][k], ')');
}
k++;
}
k = 0;
}
}
------------------------------------------------------------
Output
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection:1
1 Hilton
2 BstWestern
3 HolmesEstates
4 MoriarityInn
Select a hotel:3
*** Rooms at HolmesEstates:
HolmesEstates-Standard($145)
HolmesEstates-Queen($175)
HolmesEstates-King($250)
HolmesEstates-Suite($350)
HolmesEstates-Presidential($400)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection:2
1 Standard
2 Queen
3 King
4 Suite
5 Presidential
Select a room:2
*** Hotels with room Queen::
Hilton-Queen($75)
BstWestern-Queen($125)
HolmesEstates-Queen($175)
MoriarityInn-Queen($400)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection:3
Enter the maximum price in dollars you will pay: 100
*** Rooms less than $100:
Hilton-Standard($50)
Hilton-Queen($75)
BstWestern-Standard($75)
*** Main Menu ***
1. Display by hotel
2. Display by room type
3. Display by price limit
4. Exit program
Please make a selection:4
GOODBYE!
Needs to be coded in c, main needs to take command line arguments, thus: int main(int...
C Language Programming. Using the program below - When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the...
#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } } return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...
I need to complete the C++ program for hotel reservation. In the main cpp you have to display the hotel information from the hotel.txt based on customer preferences(which can be taken from the User.txt) For example, if the customer's budget is 200$, then only the hotels with prices below that amount should be displayed. Then the user has an option to choose which one to reserve for the particular time(which also can be found in the user.txt) The last two...
Modify When executing on the command line having only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with your new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the command line to be tested...
Code in C++: Please help me fix the error in function: void write_account(); //function to write record in binary file (NOTE: I able to store data to a txt file but however the data get error when I try to add on data the second time) void display_all(); //function to display all account details (NOTE: This function is to display all the info that save account.txt which is ID, Name, and Type) void modify_account(int); //function to modify record of file...
Please, please help with C program. This is a longer program, so take your time. But please make sure it meets all the requirements and runs. Here is the assignment: I appreciate any help given. Cannot use goto or system(3) function unless directed to. In this exercise you are to create a database of dogs in a file, using open, close(), read, write(), and Iseek(). Do NOT use the standard library fopen() ... calls! Be sure to follow the directions!...
Lab 5 Areas.cpp Marisol Castellanos villa #include # include using nanespace std; int main // ?NCLUDE ANY NEEDED FILES HERE ciostrean cmath.ho const double PI 3.14159 DEFINE THE NAMED CONSTANT PI HERE AND SET ITS VALUE TO 3.14159 oat c radius, c area; loat s side, s area float t-height, tvidth, tarea; int choice: char ch; de // DECLARE ALL NEEDED VARIABLES HERE. GIVE EACH ONE A DESCRIPT?VE /I NAME AND AN APPROPRIATE DATA TYPE coutec"Progran to calculate areas of...
C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please help me figure out. Thanks. C++ BST implementation (using a struct) Enter the code below, and then compile and run the program. After the program runs successfully, add the following functions: postorder() This function is similar to the inorder() and preorder() functions, but demonstrates postorder tree traversal. displayParentsWithTwo() This function is similar to the displayParents WithOne() function, but displays nodes having only two children....
C++ Question Question 3 [43] The Question: You are required to write a program for an Online Tutoring Centre to determine the weekly rate depending on the number of sessions the students attend and then to calculate total revenue for the center. The Online Tutoring Centre charges varying weekly rates depending on the on grade of the student and number of sessions per week the student attends as shown in Table 1 below. Grade 8 9 Session 1 75 80...
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...