116k views
2 votes
Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate a long as product contains a value less than 100

1 Answer

5 votes

Answer:

//begins

var int product = 0;

while (product < 100) {

product = enterNumber();

product = product*10;

}

//ends

This is the pseudo code of the while loop that accomplish the condition.

Step-by-step explanation:

If you want to do it in Java for example, then you have to import the class Scanner first:

//begins

import java.util.Scanner;

Scanner keyboard = new Scanner(System.in);

while (product < 100) {

int product = keyboard.nextInt();

product = product*10;

}

//ends

Important: Have to set the variable product = 0 before it enters on the while loop.

User Quarkonia
by
8.0k points