![police76](/avatars/16996.jpg)
police76
03.11.2020 •
Computers and Technology
You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an error message and will ask the user to input the data again (use a do / while loop). Invalid values include:
Solved
Show answers
More tips
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
Answers on questions: Computers and Technology
- C Computers and Technology Jim is expecting a very busy weekend at his store, so he sent the following e-mail to his employees: ALL EMPLOYEES MUST WORK THIS WEEKEND. NO TIME OFF WILL BE GRANTED....
- C Computers and Technology Suppose that you are given the following program. after the instruction mov ebp, esp , which of the following is referenced by each of the following? .data x dword 153461...
- C Computers and Technology When viewing a syslog message, what does a level of 0 indicate? a. the message represents debug information. b. the message is a warning condition on the system. c. the...
- C Computers and Technology In a half-page essay outline the following three tunneling mechanisms: the isatap tunneling mechanism, including its components, addressing, routing and router configuration;...
- C Computers and Technology At what point is a packet considered to be a giant? a. it becomes a giant when it exceeds the medium s maximum packet size. b. it becomes a giant when it exceeds 1500 bytes....
- C Computers and Technology The grouping of multiple servers so that they appear as a single device to the rest of the network is known as which term? a. server overloading b. link aggregating c....
- C Computers and Technology Most unix and linux desktop operating systems provide a gui application for easily viewing and filtering the information in system logs. true false...
- M Mathematics The swimming club went to a swim meet in another town. They took 3 cars and 2 vans. There were 5 people in each car and 4 people in each van. How many people went on the...
- E English 1. How does Nick feel about Gatsby and Daisy s relationship in chapter 8?...
- H History Supporters of the New Jersey plan...
Ответ:
See explanation (Program written in C++)
Explanation:
The question is incomplete as the invalid values were not included in the question.
However, to make the sense of it, I'll answer your question using the following conditions.
1. Invalid values include: Numbers less than 0 (See comments for explanations)
#include <iostream>
using namespace std;
int main() {
//This line declares num (for user input)
int num;
//The following iteration keeps repeating itself until a number greater than 0 is entered using do while loop
do{
//This line prompts user for input
cout<<"Numbers greater than 0: ";
//This line gets input from the user
cin>>num;}
while(num<1);//This condition checks for valid user input
cout<<"You entered: "<<num; //This line prints out the user input
}
2. Invalid values include: Odd Numbers
I'll make use of the above code (in 1)
Start by replacing:
cout<<"Numbers greater than 0: ";
with
cout<<"Even Numbers: "; //This prompts user for even numbers
Replace
while(num<1);
with
while(num%2==1); //This checks if input is odd. If yes, the loop is repeated
3. Invalid values include: Even Numbers
I'll make use of the above code (in 1)
Start by replacing:
cout<<"Numbers greater than 0: ";
with
cout<<"Odd Numbers: "; //This prompts user for Odd numbers
Replace
while(num<1);
with
while(num%2==0); //This checks if input is even. If yes, the loop is repeated
Ответ: