Question

In: Computer Science

This code needs to be in C++, please. Step 1: Add code to prompt the user...

This code needs to be in C++, please.

Step 1: Add code to prompt the user to enter the name of the room that they are entering information for. Validate the input of the name of the room so that an error is shown if the user does not enter a name for the room. The user must be given an unlimited amount of attempts to enter a name for the room.

Step 2: Add Input Validation to the code using the following rules:

  • The length of the room cannot be less than 5 feet
  • The width of the room cannot be less than 5 feet
  • The user's menu selection for the amount of shade should be 1, 2, or 3.

If the user's input is invalid, the program should display an appropriate error message and prompt the user to re-enter their input. The user should be given an unlimited amount of attempts to enter valid input

Step 3: Add code to have the program ask the user if they would like to enter information about another room after the information for a previous room has been processed and displayed. The user should be able to enter a "y" or "Y" to indicate that they want to enter information about another room. See the Sample Input and Output for how to format this.

Step 4: After the user has indicated that they do not wish to enter information about another room, the program should output the number of rooms that have been entered and then stop executing.

Sample Input and Output (user input is in bold) - The output of your program should match the formatting and spacing exactly as shown

Please enter the name of the room: Guest Bedroom
Please enter the length of the room (in feet): 15.5
Please enter the width of the room (in feet): 10
What is the amount of shade that this room receives?

  1. Little Shade
  2. Moderate Shade
  3. Abundant Shade

Please select from the options above: 3

Air Conditioning Window Unit Cooling Capacity

Room Name: Guest Bedroom
Room Area (in square feet): 155.0
Amount of Shade: Abundant
BTUs Per Hour needed: 4,950

Would you like to enter information for another room (Y/N)? Y

Please enter the name of the room: Kitchen
Please enter the length of the room (in feet): 20
Please enter the width of the room (in feet): 15
What is the amount of shade that this room receives?

  1. Little Shade
  2. Moderate Shade
  3. Abundant Shade

Please select from the options above: 2

Air Conditioning Window Unit Cooling Capacity

Room Name: Kitchen
Room Area (in square feet): 300.0
Amount of Shade: Moderate
BTUs Per Hour needed: 10,000

Would you like to enter information for another room (Y/N)? N

The total number of rooms processed was: 2

Solutions

Expert Solution

here is a code with output snippet for above problem.

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int count =0;     // to count the number of rooms
    

   // choice is to store the choice of user for entering more record 

    char choice = 'y'; 
 
   // while loop until the choice is yes

    while (choice == 'y' || choice =='Y')
    {
        count++;
        string room_name;
        cout<<"Please enter the name of the room : ";
        
        getline(cin, room_name);
        cout<<endl;
        
        double len;         // len variable to store the length of the room
        double wid;         // wid variable to store the width of the room
        
         
                           // create a label uplen in case user entered invalid length

        uplen:                
        cout<<"Please enter the length of the room (inj feet): ";
        cin>>len;
        if(len <5)         // check for the validity of length
        {
            cout<<endl<<"Invalid room length please enter again";
            goto uplen;
        }
        
                           // create a label upwid in case user entered invalid width 

        upwid:      
        cout<<endl<<"Please enter the width of the room (in feet): ";
        cin>>wid;
        if(wid <5)           // check for the validity of the width
        {
            cout<<endl<<"Invalid room width please enter again";
            goto upwid;
        }
        
        cout<<endl<<"What is the amount of shade that this room receives? "<<endl;
        cout<<"Little Shade"<<endl<<"Moderate Shade"<<endl<<"Abundant Shade"<<endl;
        cout<<"Please select the option above";

                           // op variable is to store the option ie 1 2 or 3

        int op;
        cin>>op;             
        

                            // print the output to the console with recorded information

        cout<<"Air Conditioning Window Unit Cooling Capacity"<<endl;
        cout<<"Room name : "<<room_name<<endl;
        cout<<"Room Area ( in square feet ): "<<double(len*wid)<<endl;
        cout<<"Amount of shade: ";
        
        if(op == 1)
        cout<<"Little";
        else if(op ==2)
        cout<<"Moderate";
        else
        cout<<"Abundant";
        

                         // ask the user if needs to enter more info
        cout<<endl<<"Would you like to enter information for another room (Y/N)?";
        cin>>choice;
        char ch = cin.get();
    }
    cout<<endl<<"The total number of rooms processed was: "<<count;
        
        
        
    

    return 0;
}

I actually dont know how to calculate btus per hour neede also you have not mentioned it ... once you tell me i can do it but the code is otherwise complete .

here is the output snippet


Related Solutions

C code please (1) Prompt the user to enter a string of their choosing. Store the...
C code please (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in a number greater than or equal to zero and less than or equal to 100. If they do not you should alert them and end the program. Next, determine the letter grade associated with the number. For example, A is any grade between 90 and 100. Report the letter grade to the user.
Using map - java - eclipse Prompt the user for the skillset to add. A skillset...
Using map - java - eclipse Prompt the user for the skillset to add. A skillset can be any String. Examples of skillsets are: “java” “software design”, “databases”, etc. Add the skillset to the logged in user’s skillsets and then provide a response to the logged in user indicating that their skillset has been added (e.g. “Java has been added to your skillsets.”). You don’t have to display any additional messages if the user added a duplicate skillset. In this...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                       ...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names             Quit If the user selects Guess-number, your program needs to call a user-defined function called int guess-number ( ). Use random number generator to generate a number between 1 – 100. Prompt the user to guess the generated number and print the following messages. Print the guessed number in main (): Guess a number: 76 96: Too large 10 Too small 70 Close...
*******************In Python please******************* (1) Prompt the user to enter a string of their choosing. Store the...
*******************In Python please******************* (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more...
Also please add comments on the code and complete in C and also please use your...
Also please add comments on the code and complete in C and also please use your last name as key. The primary objective of this project is to increase your understanding of the fundamental implementation of Vigenere Cipher based program to encrypt any given message based on the Vignere algorithm. Your last name must be used as the cipher key. You also have to skip the space between the words, while replicating the key to cover the entire message. Test...
Prompt the user for their name, get and store the user input. Prompt the user for...
Prompt the user for their name, get and store the user input. Prompt the user for their age, get and store the user input. We will assume that the user will enter a positive integer and will do no error checking for valid input. Determine and store a movie ticket price based on the user's age. If their age is 12 or under, the ticket price is $5. If their age is between 13 and 64, inclusive, the ticket price...
Step by step in python please Write a program this will read a file (prompt for...
Step by step in python please Write a program this will read a file (prompt for name) containing a series of numbers (one number per line), where each number represents the radii of different circles. Have your program output a file (prompt for name) containing a table listing: the number of the circle (the order in the file) the radius of the circle the circumference the area of the circle the diameter of the circle Use different functions to calculate...
IN C This assignment is to write a program that will prompt the user to enter...
IN C This assignment is to write a program that will prompt the user to enter a character, e.g., a percent sign (%), and then the number of percent signs (%) they want on a line. Your program should first read a character from the keyboard, excluding whitespaces; and then print a message indicating that the number must be in the range 1 to 79 (including both ends) if the user enters a number outside of that range. Your program...
use c++ (1) Prompt the user for a title for data. Output the title. (1 pt)...
use c++ (1) Prompt the user for a title for data. Output the title. (1 pt) Ex: Enter a title for the data: Number of Novels Authored You entered: Number of Novels Authored (2) Prompt the user for the headers of two columns of a table. Output the column headers. (1 pt) Ex: Enter the column 1 header: Author name You entered: Author name Enter the column 2 header: Number of novels You entered: Number of novels (3) Prompt the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT