I need help writing a program, the program when running is supposed to look like
ID: 3545925 • Letter: I
Question
I need help writing a program, the program when running is supposed to look like the following ...
Explanation / Answer
#include<iostream>
using namespace std;
int main(){
int n, i;
cout << "Enter the number of guests: ";
cin >> n;
int meal[n], room[n], t_r = 0, t_m = 0, total = 0;
string r[n], first[n], last[n];
for(i = 0; i < n; i++){
cout << " Enter the room number for guest #" << i + 1 << " :";
cin >> r[i];
cout << "Enter the name for guest #" << i + 1 << " :";
cin >> first[i] >> last[i];
cout << "Enter the room charge for guest #" << i + 1 << " :";
cin >> room[i];
t_r += room[i];
cout << "Enter the meal charge for guest #" << i + 1 << " :";
cin >> meal[i];
t_m += meal[i];
}
cout << " ";
cout << "ROOM# CUST NAME ROOM CHG MEAL CHG TOTAL CHG ";
cout << "_____ __________ ________ ________ _________ ";
for(i = 0; i < n; i++){
cout << r[i] << " " << first[i] << " " << last[i] << " $" << (float)room[i] << " $" << (float)meal[i] << " $" << (float)(room[i] + meal[i]) << " ";
}
cout << " The total number of guests are: " << n;
cout << " The total room charges are: $" << t_r;
cout << " The total meal charges are: $" << t_m;
cout << " The grand total is: $" << t_r + t_m;
cout << " ";
}