IT IT 145 ZyBooks 3.18.docx - PARTICIPATION ACTIVITY 3.18.2 Do-while loop Consider the following loop count = 0 num = 6 do num = num 1 count = count 1

IT IT 145 ZyBooks 3.18.docx - PARTICIPATION ACTIVITY 3.18.2...

This preview shows page 1 - 3 out of 3 pages.

PARTICIPATIONACTIVITY3.18.2: Do-while loop.Consider the following loop:count = 0num = 6do{num = num - count = count + } while(num > 41)What is the value of count after the loop?012;;1;1;);2)What initial value of num would prevent count from being incremented?40
Background image
CHALLENGEACTIVITY3.18.1: Basic do-while loop with user input.Complete the do-while loop to output 0 to the value of countLimit using printVal. Assume the user will only input a positive number. For example, if countLimit is 5 the expected output will be0 1 2 3 4 5import java.util.Scanner;public class CountToLimit {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int countLimit;int printVal;// Get user inputcountLimit = scnr.nextInt();printVal = 0;do {System.out.print(printVal + " ");printVal = printVal +
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Summer '18
  • Scanner scnr, printVal.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture