In C program, question is below, that I met some problem and cannot fix it. Here is the original version.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In C program, question is below, that I met some problem and cannot fix it. Here is the original version.

Post by answerhappygod »

In C program, question is below, that I met some problem
and cannot fix it.
In C Program Question Is Below That I Met Some Problem And Cannot Fix It Here Is The Original Version 1
In C Program Question Is Below That I Met Some Problem And Cannot Fix It Here Is The Original Version 1 (246.75 KiB) Viewed 21 times
Here is the original version.
8 #include 9 0 #define MAX_ROOMS 50 1 2 struct hotel_room { 3 // TODO: fill this in with the details of each hotel room int room_number; 4 5 int price; 6 }; 7 8 // Prints the room in the correct format when given the room_number 9 // and price of it. 0 void print_room (int room_number, double price); 1 2 int main(void) { 3 int room_number; 4 double price; 5 int rooms; 5 int i = 0; 7 printf("How many rooms? "); 3 scanf("%d", &rooms); 9 // TODO: scan in how many rooms in the hotel 0 1 printf("Enter hotel rooms: \n"); 2 // TODO: scan in the details of each hotel room 3 4 while (i< rooms) { 5 scanf("%d %lf", &room_number, &price); i++; 5 7 } 3 printf("Room List: \n"); // TODO: print all the rooms scanned in print room (room number, price); 9 O 1
First, it scans in the number of rooms in the hotel. Then, it scans in the details of each room: its number and its price. Afterwards, it prints out a list of all the rooms and their prices. $ ./hotel rooms How many rooms? 3. Enter hotel rooms: 101 123.45 201 399.99 301 699.99 Room List: Room 101 @ $123.45 Room 201 @ $399.99 Room 301 @ $699.99 $ ./hotel rooms How many rooms? 2 Enter hotel rooms: 101 299 102 399.5 Room List: Room 101 @ $299.00 Room 102 @ $399.50 /hotel_rooms How many rooms? 5 Enter hotel rooms: 101 299.99 102 399.9 201 349.99 202 430 301 667.66 Room List: Room 101 @ $299.99 Room 102 @ $399.90 Room 201 @ $349.99 Room 202 @ $430.00 Room 301 @ $667.66
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply