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
The Microsoft-NanoServer-Guest-Package installs the drivers necessary for installing Nano Server as a host OS on a physical mach
Lena [83]

Answer:

False.

Explanation:

The Microsoft-NanoServer-Guest-Package does not install the necessary drivers for the installation of the Nano Server on a system as a host OS.

Nano Server is mostly used for images.The Nano Server is a tool used to create custom nano server images with the help of graphical interface and also bootable USB media.

8 0
3 years ago
The scheme function (mult2-diff Ist) should take one argument, a list of numbers, and results in multiplying each number in the
JulijaS [17]

Answer:

The solution code is written in Python.

  1. def mult2_diff(lst):
  2.    num_list = []
  3.    for x in lst:
  4.        num_list.append(x * 2)
  5.    diff = num_list[0]
  6.    for i in range(1, len(num_list)):
  7.        diff = diff - num_list[i]
  8.    
  9.    print(diff)

Explanation:

Firstly, based on the requirement stated in the question, define a function <em>mult2_diff() </em>that takes one argument, <em>lst</em>, which is a list of numbers (Line 1).

This function is expected to multiply each number in the list by two and then followed with computing the difference. To do so, let's try to attempt the first function task, multiplying numbers.  Create a new list, num_list, to hold the multiplied numbers (Line 2). Use a for loop to traverse through each number in the input list, <em>lst</em>, and multiply each of them by two and add it to the <em>num_list </em>(Line 4-5).

To attempt the second function task, create another variable, <em>diff</em>, to hold the value of calculated difference between the numbers in the <em>num_list</em>. Initialize <em>diff </em>with the first number in the <em>num_list</em>. Use a another for-loop to traverse through each number in the num_list starting with second index, <em>1</em>, and calculate the difference between the <em>diff </em>and the current number extracted from the <em>num_list </em>through indexing.

At last print the output of <em>diff</em> (Line 11).

6 0
3 years ago
The largest country in South America
ioda

Answer:

it's argentinian

Explanation:

7 0
3 years ago
In the Happy Valley School System, children are classified by age as follows: less than 2, ineligible 2, toddler 3-5, early chil
sasho [114]

// C++ switch

// It can also be used for JAVA, C#

switch(age){

// here age will be sent by the function in which it is used

// case to check the age<2

case(age<2 && age>0):

// printing the line

cout<<"ineligible";

// case to check the age ==2

case(age==2):

// printing the line

cout<<"toddler";

// case to check 3-5

case(age>=3 && age<=5):

cout<<"early childhood";

// case to check 6-7

case(age==6 || age==7):

cout<<"young reader";

//case to check 8-10

case(age>=8 && age<=10):

cout<<"elementary";

// case to check 13

case(age==13):

cout<<"impossible";

//case tocheck 14-16

case(age>=14 && age<=16):

cout<<"high school";

// case to check 17 or 18

case(age==17 || age==18):

cout<<"scholar";

//case to check >18

case(age>18);

cout<<"ineligible";

// default case

default:

cout<<"Invalid age";

}

Read more on Brainly.com - brainly.com/question/12981906#readmore

5 0
3 years ago
Need answer ASAP. No links
DIA [1.3K]

Answer:

A <b>

Normally AD and BC are written in bold letters.

for example : The terms anno Domini (AD) and before Christ (BC).

Within available option the best option to choose is <b> hope it helped

5 0
2 years ago
Other questions:
  • By issuing concert tickets on the blockchain, fans can verify transfer of ownership from one digital wallet to another, rather t
    14·1 answer
  • Your project must satisfy the following requirements:
    7·1 answer
  • What part of the computer gives access to the internet
    10·1 answer
  • how to answer the questions on brainly? I've typed my answer in the box but there's no submit button or whatever, and the only t
    14·2 answers
  • Plz answer me will mark as brainliest picture included ​
    15·1 answer
  • Select the correct answer.
    12·1 answer
  • Which of the following is NOT contained on the Slide Show toolbar?
    11·2 answers
  • Ergonomically designed workstations and equipment reduce stress-related injuries and improve the productivity and efficiency of
    13·2 answers
  • In the language of the World Wide Web, "this page cannot be displayed" means A. your computer's software is damaged. B. the ISP
    10·2 answers
  • I still haven't figured out how to award someone branliest will someone help me? If you explain to me how to do it i will do awa
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!