How to write simple programs that get input from the user, produce output, perform simple calculations, and make decisions

Purpose
In this assignment, you will demonstrate how to write simple programs that get input from the user, produce output, perform simple calculations, and make decisions.
Instructions
Assignment Header
At the top of each of your C++ programs, you should have at least four lines of documentation:
Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example:

/* Program name: jbtictactoe.cpp
*  Author: John Doe
*  Date last updated: 5/1/2017
* Purpose: Play the game of Tic-Tac-Toe
*/

Assignment: Computer Specifications
This program will determine if a user has enough RAM to do certain tasks.
Prompt the user for the amount of RAM their computer has in GB. Then you will display the list of tasks below that the user might do with the computer. Based on the task chosen, inform the user if the amount of RAM they have is sufficient.
Tasks with minimum RAM requirements:

Task
Minimum RAM Needed
Android Studio
12 GB
Visual Studio Code
8 GB
Gaming
16 GB
Web Browsing with Chrome
8 GB
Multiple Programming Tasks (both Android and VS Code)
20 GB
Zoom
8 GB
Email
6 GB
Create and edit documents
6 GB
Everything listed above
32 GB

Input Validation
The user will be entering a number for the RAM amount. You will need to make sure that the user properly enters a number into the console by checking if they have input failure, and you will need to make sure the number is greater than 0. If the input fails either condition, the program should display an error message and exit early.
The way a user chooses a task is through a numbered menu. You will need to make sure the user properly enters a number into the console by checking if they have input failure, and you will need to make sure the number entered is within the range of the menu options. If the input fails either condition, then the program should display an error message and exit early.
Sample Output

Enter the amount of RAM in GB
8
Choose the task you want to do on your computer from the following list:
1. Android Studio
2. Visual Studio Code
3. Gaming
4. Web Browsing with Chrome
5. Multiple Programming Tasks (both Android Studio and Visual Studio Code)
6. Zoom
7. Email
8. Create and edit documents
9. Everything listed above
6
Congratulations! You have sufficient RAM for your task.
Enter the amount of RAM in GB
10
Choose the task you want to do on your computer from the following list:
1. Android Studio
2. Visual Studio Code
3. Gaming
4. Web Browsing with Chrome
5. Multiple Programming Tasks (both Android Studio and Visual Studio Code)
6. Zoom
7. Email
8. Create and edit documents
9. Everything listed above
5
Sorry the RAM you have is not sufficient.
Enter the amount of RAM in GB
a
You have entered an invalid value. The program will unable to continue. Exiting.
Enter the amount of RAM in GB
-1
You have entered an invalid value. The program will unable to continue. Exiting.
Enter the amount of RAM in GB
8
Choose the task you want to do on your computer from the following list:
1. Android Studio
2. Visual Studio Code
3. Gaming
4. Web Browsing with Chrome
5. Multiple Programming Tasks (both Android Studio and Visual Studio Code)
6. Zoom
7. Email
8. Create and edit documents
9. Everything listed above
a
You have entered an invalid value.  The program will be unable to continue. Exiting.
Enter the amount of RAM in GB
8
Choose the task you want to do on your computer from the following list:
1. Android Studio
2. Visual Studio Code
3. Gaming
4. Web Browsing with Chrome
5. Multiple Programming Tasks (both Android Studio and Visual Studio Code)
6. Zoom
7. Email
8. Create and edit documents
9. Everything listed above
11
You have entered an invalid value.  The program will be unable to continue. Exiting.

Hey @SupandeepkaurRa, welcome to the community!

We cannot give you the exact answer as this is an assignment, but we can point you in the right direction.

To get input in C++, you can use std::cin >>. To output, use std::cout << "text"

If you need more help on something specific, feel free to ask!

3 Likes