Answer to Question #149004 in C++ for Gerald

Question #149004
Make a program that will input type of accommodation room. A-for first class, B-for second
class. Charge as follows : first class=800.00 and second class = 650.00. Your program will be
terminated if you input C in the accommodation room type.
Expert's answer
1
Expert's answer
2020-12-06T10:22:49-0500
#include <iostream>


using namespace std;


int main()
{
    // We make array for placing room types including A, B, C
    char arrRoomTypes[4] = {'A', 'B', 'C', '\0'};
    while (true) {
        // We declare a variable for input the types of rooms
        char roomType;
        cout << "Enter the type of room: ";
        cin >> roomType;
        // we compare entered room type with array room types
        if (roomType == arrRoomTypes[0]) {
            cout << "first class - 800$" << endl;
        }
        else if (roomType == arrRoomTypes[1]) {
            cout << "second class - 650$" << endl;
        }
        else if (roomType == arrRoomTypes[2]) {
            cout << "Sorry! we haven't this kind of room" << endl;
            break;
        }
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog