Question: Java: fill in code. import java.util.*; public class Chapter6_FillInTheCode { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); // exercise 21 //
Java: fill in code.
import java.util.*; public class Chapter6_FillInTheCode { public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
// exercise 21 // write a while loop that generates random integers between 3 and 7 until a 5 is generated // and prints them all out, excluding 5 Random random = new Random(); int i = random.nextInt( 5 ) + 3; // prime read
// your code goes here
// exercise 22 // write a while loop that takes an integer input from the user, then prompts for additional integers // and prints all integers that are greater than or equal to the original input until the user enters 20, // which is not printed System.out.println("Enter a starting integer > "); int start = keyboard.nextInt(); // prime read
// your code goes here
// exercise 23 // write a while loop that takes integer values as input from the user and finds the sum of those // integers until the user types in the value -1 which is not added System.out.println("Enter an integer value. enter -1 to stop >"); int value = keyboard.nextInt(); // prime read
// your code goes here
// exercise 25 // write a while loop that takes words as input from the user and concatenates them until // the user types in the word "end" which is not concatenated String sentence = ""; String word = keyboard.next(); // prime read
// your code goes here
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
