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.
​​​​​​​in c code Add an intro screen Ask the user for their name, what type of...
​​​​​​​in c code Add an intro screen Ask the user for their name, what type of cookie they would like to order and how many. The types are sugar, chocolate chip, and peanut butter. Assign a cost to each cookie. Show total for cookie purchase and ask if the would like to place another order. Include at least one function and one loop. Add one extra feature. For example, a sample execution of your code would be as follows: Cookie...
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...
1. Write a program in C++ to find the factorial of a number. Prompt the user...
1. Write a program in C++ to find the factorial of a number. Prompt the user for a number and compute the factorial by using the following expression. Use for loops to write your solution code. Factorial of n = n! = 1×2×3×...×n; where n is the user input. Sample Output: Find the factorial of a number: ------------------------------------ Input a number to find the factorial: 5 The factorial of the given number is: 120 2. Code problem 1 using While...
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...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT