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
tiny-mole [99]
3 years ago
9

Complete the do-while loop to output every number form 0 to countLimit using printVal. Assume the user will only input a positiv

e number. For example, if countLimit is 5 the expected output will be 0 1 2 3 4 5
import java.util.Scanner;

public class CountToLimit {

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

int countLimit = 0;

int printVal = 0;

// Get user input

countLimit = scnr.nextInt();

printVal = 0;

do {

System.out.print(printVal + " ");

printVal = printVal + 1;

} while ( /* Your solution goes here */ );

System.out.println("");

return;

}

}

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 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
import java.util.Scanner;

public class NumberPrompt {

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

int userInput = 0;

/* Your solution goes here */

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

return;

}

}
Computers and Technology
1 answer:
elena-s [515]3 years ago
7 0

Answer:

PART ONE

  1. import java.util.Scanner;
  2. public class CountToLimit {
  3.    public static void main(String[] args) {
  4.        Scanner scnr = new Scanner(System.in);
  5.        int countLimit = 0;
  6.        int printVal = 0;
  7.        // Get user input
  8.        System.out.println("Enter Count Limit");
  9.        countLimit = scnr.nextInt();
  10.        do {
  11.            System.out.print(printVal + " ");
  12.            printVal = printVal + 1;
  13.        } while ( printVal<=countLimit );
  14.        System.out.println("");
  15.        return;
  16.    }
  17. }

PART TWO

  1. import java.util.Scanner;
  2. public class NumberPrompt {
  3.    public static void main (String [] args) {
  4.        Scanner scnr = new Scanner(System.in);
  5.        System.out.print("Your number < 100: ");
  6.       int  userInput = scnr.nextInt();
  7.      do {
  8.           System.out.print("Your number < 100: ");
  9.           userInput = scnr.nextInt();
  10.       }while (userInput>=100);
  11.        System.out.println("Your number < 100 is: " + userInput);
  12.        return;
  13.    }
  14. }

Explanation:

In Part one of the question, The condition for the do...while loop had to be stated this is stated on line 14

In part 2, A do....while loop that will repeatedly prompt user to enter a number less than 100 is created. from line 7 to line 10

You might be interested in
What does JPEG stand for?
ArbitrLikvidat [17]
Joint Photographic Experts Group
7 0
3 years ago
Read 2 more answers
Can you help me with this?
kramer

Answer:lol :)

Explanation:

Yes, the special order is 6 5 and 7 and it is/

3 0
3 years ago
Write three tasks students can preform in a digital classroom?
Nadya [2.5K]

Students can perform several tasks in a digital environment. For example, they can watch instructional videos, take notes, and participate in peer discussions.

this is the right answer .just did it

7 0
3 years ago
Read 2 more answers
Most mobile devices include, among other features, ______ functionality.
AfilCa [17]
PIM would be the answer. Hope this helps. :)
4 0
3 years ago
May someone help please. :(
BigorU [14]

the 3rd one, if you ever watched a dvd (i know you have) if you read the copyright note you can be fined and you may end up in jail (for five or two years depending on what you did)

7 0
3 years ago
Other questions:
  • How to remove a channel from favorite list on suddenlink?
    15·1 answer
  • Where is the spell checker found in excel?
    7·2 answers
  • Write a program to calculate the area of a triangle whose base is 10cm and height is 6cm
    6·1 answer
  • how many usable host addresses are available for each subnet when 4 bits are borrowed from a class C IP address
    11·1 answer
  • Hi wanna play fortnite tomorrow add me im batjoker09 no caps or spaces
    13·1 answer
  • Computer identity theft differs from theft in the real world in what major way?
    11·2 answers
  • Can development and conservation of environment go hand-in-hand? Explain your point of view
    8·1 answer
  • How do you properly turn off a computer?
    8·2 answers
  • An incident response plan should be created be for a software system is released for use.
    10·1 answer
  • Five programs are currently being run in a computer. Program 1 is using 10 GiB of RAM, program 2 is using 5 GiB of RAM, program
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!