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]
2 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]2 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
Which of the following is not a true statement? You can import a table or a query directly from an Access database into an Excel
Lilit [14]

Answer:

does anybody know this answer?

Explanation:

no nobody does

5 0
3 years ago
Often an extension of a memorandum of understanding (MOU), the blanket purchase agreement (BPA) serves as an agreement that docu
Alchen [17]

Answer:

FALSE

Explanation:

The blanket purchase agreement (BPA) can not serves as an agreement that documents the technical requirements of interconnected assets but the Interconnection service agreement (ISA).

3 0
2 years ago
Is this statement true or false? You can apply only one of these at a time: underline, bold, or italics. true false
Lelechka [254]
I think false not sure but let other people help u answer and u can decide
8 0
3 years ago
Why is group design better or worse for coding projects ?....will report for a dum answer U ` U
DedPeter [7]

there are many styles of coding think about it like art if you had 15 painters working on the same 4x4 painting it would look like a mess.

-scav

8 0
2 years ago
Match the cell reference to its definition
Alisiya [41]

Answer:

which cell reference:-|

6 0
3 years ago
Read 2 more answers
Other questions:
  • A coworker asks your opinion about how to minimize ActiveX attacks while she browses the Internet using Internet Explorer. The c
    14·1 answer
  • What is the name of the port that you plug an ethernet network cable into?
    6·1 answer
  • Life can get busy and hectic but relationships matter what is an effective way to mending relationships that may have been negle
    9·1 answer
  • In cell R9, enter a formula using the AVERAGEIF function to determine the average number of years of experience for lifeguards.
    12·1 answer
  • The official record of a high school student's performance is called:
    6·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 then the outp
    12·1 answer
  • Code embedded into an HTML page and downloaded by a user; resides on the client and helps process Web form input. Common clients
    9·1 answer
  • When a person bullies someone using technology, it's called:
    9·2 answers
  • a matched-pairs t-test is not an appropriate way to analyze data consisting of which of the following?
    11·1 answer
  • How to give a brainiest on a question? if you teach me i will give brainiest
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!