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
Ostrovityanka [42]
2 years ago
10

Imagine that you wanted to write a program that asks the user to enter in 5 grade values. The user may or may not enter valid gr

ades, and you want to ensure that you obtain 5 valid values from the user. Which nested loop structure would you use?
A. A "for" loop inside of a "while" loop
B. A "while" loop inside of a "for" loop
C. None of the above
D. Either a or b would work
Computers and Technology
1 answer:
OLEGan [10]2 years ago
5 0

Answer:

B. A "while" loop inside of a "for" loop

Explanation:

To enter 5 grade values, a for loop can be used to specify the number of grade values to be entered by the user, in other to ensure the validity of the grade values entered by the user, the while loop will be used inside the for loop such that the inputted values will only be accepted when the user enters a valid grade.

Code structure :

For a in range(0, 5) :

grade = input()

while grade (enter condition)

This is just the code structure and this will work for the problem stated.

You might be interested in
What is an easy and accurate way that a graphic designer can increase the size of a digital shape while keeping the ratio of hei
VikaD [51]

Answer:

Open the shape’s properties window, and type the height value multiplied by 2 and the width value multiplied by 3.

Explanation:

7 0
3 years ago
Read 2 more answers
What is your perception of what a safe classroom looks like
Andreyy89

Answer:

6 feet apart

Explanation:

6 0
3 years ago
Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a
anzhelika [568]

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

7 0
3 years ago
What is the difference between paper size and page margins in word
yKpoI14uk [10]
Paper size is how big or small the paper is whilst paper margin is the staight lines or shapes at the sides of a page or sheet.
6 0
2 years ago
Read 2 more answers
What job title is used for the person who uses the server operating system to add and remove users, install software, and admini
yan [13]
System Administrator
7 0
3 years ago
Other questions:
  • what is a massive online storage that allows for access by any Internet connected device running a web browser and is used for l
    7·1 answer
  • Information is a valuable asset and not everyone in the world can be trusted with it. Therefore, we need to protect our valuable
    10·1 answer
  • Does the steelseries arctis 9x work with a pcie bluetooth card in windows
    13·1 answer
  • On the pie chart below, which “slice” represents 30% of the budget?
    8·1 answer
  • Mobile apps known as news _________ collect articles from a variety of sources and present them to you in a magazine-style forma
    7·2 answers
  • A friend asks you for help writing a computer program to calculate the square yards of carpet needed for a dorm room. The statem
    15·1 answer
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST AND COMPATIBLE FOR 3D PRINTERS?
    12·1 answer
  • The area of the spreadsheet highlighted in red is the _____.
    12·1 answer
  • What is the abuse of electronic messaging systems to indiscriminately send unsolicited bulk messages, many of which contain hoax
    5·1 answer
  • How ict tools changed the way we live explain it​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!