1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Brrunno [24]
3 years ago
14

You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e

rror message and will ask the user to input the data again (use a do / while loop). Invalid values include:
Computers and Technology
1 answer:
alukav5142 [94]3 years ago
8 0

Answer:

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

You might be interested in
____ is the security guarantee that people who intercept messages cannot read them. A. Availability B. Encryption C. Confidentia
Anni [7]

Answer:

C. Confidentiality

Explanation:

With confidentiality, a person who intercepts messages you intend to remain private cannot read them and thus increases your document protection

8 0
2 years ago
What data type or you use to represent true or false values?
vfiekz [6]
The Boolean type is used to represent true or false values
3 0
2 years ago
EXERCISE
nirvana33 [79]

Answer:

1. True

2. True

3. False

4. True

5. True

8 0
2 years ago
According to the SANS Institute, a __________ is typically a document that outlines specific requirements or rules that must be
nata0808 [166]
That’s should be in the quizlet I think..
7 0
3 years ago
The _____ unit is the preferred style unit for web page text because it makes it easy to develop pages in which different page e
cluponka [151]
Em The answer that you are looking for is (em)
6 0
3 years ago
Read 2 more answers
Other questions:
  • Literacy is best defined as knowing how to: (Points : 1)
    7·2 answers
  • You will start by doing a bit of research on viewfinders and LCD displays on digital cameras. After you feel that you have an un
    10·1 answer
  • ____ are the computers that store network software and shared or private user files.
    6·1 answer
  • As a computer science student, which career you will select and what do you predict about the future of that specific IT-Career.
    8·1 answer
  • How do you change your age on Brainly?
    10·1 answer
  • Provide an example where a company has demonetized a market or industry.
    8·1 answer
  • Implement the function printTwoLargest that inputs an arbitrary number of positive numbers from the user. The input of numbers s
    14·1 answer
  • Ian kno da answer tell me
    7·2 answers
  • A malicious actor is preparing a script to run with an excel spreadsheet as soon as the target opens the file. the script includ
    12·1 answer
  • Trent is researching what it would take to become a pharmaceutical scientist. What academic requirements should he complete?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!