Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with a newline. Ex: For the user input 123, 395, 25, the expected output is:

Enter a number (<100):
Enter a number (<100):
Enter a number (<100):
Your number < 100 is: 25
c++


#include
using namespace std;

int main() {
int userInput = 0;

do
cout << "Your number < 100 is: " << userInput << endl;

return 0;
}

Respuesta :

Answer:

#include <iostream>

using namespace std;

int main()

{

   int userInput = 0;

   do {

       cout << "Enter a number (<100):" << endl;

       cin >> userInput;

   }

   while(userInput >= 100);

   cout << "Your number < 100 is: " << userInput << endl;

   return 0;

}

Explanation:

Inside the do part, ask user to enter a number and get that number.

In the while, check if the number is greater than or equal to 100. It is going to keep asking to enter a number until a number that is smaller than 100 is entered.

Print out the number that is smaller than 100.

Answer:

import java.util.Scanner;

public class NumberPrompt {

  public static void main (String [] args) {

     Scanner scnr = new Scanner(System.in);

     int userInput = 0;

     

     do {

         System.out.println("Enter a number (<100):");  

         userInput = scnr.nextInt();

     }

       while(userInput >= 100);

     System.out.println("Your number < 100 is: " +userInput);

     

     

        }

}

   

           

         

Explanation:

Answer in java

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE