Question: Introduction To Java For Loops And While Loops Learning Objectives: Using for loops and while loops to repeat code. Comparison of the same lab exercises


Introduction To Java For Loops And While Loops Learning Objectives: Using for loops and while loops to repeat code. Comparison of the same lab exercises with these two loop types. Repetition Write some Java code that uses a for loop to print out the word Repetition six times. One To Hundred Write some Java code that uses a for loop to print out the numbers 1 - 100 inclusive. Even Numbers To Twenty Write some Java code that uses a for loop to print all the even numbers 2 20 inclusive. Can you do this in two different ways? Name And Number Write some Java code that asks the user for their name and a number. Your code must use a for loop to print the user's name the required number of times. Repetition 2 Write some Java code that uses a while loop to print out the word Repetition" six times. One To Hundred 2 Write some Java code that uses a while loop to print out the numbers 1 - 100 inclusive. Even Numbers To Twenty 2|| Write some Java code that uses a while loop to print all the even numbers 2 20 inclusive. Can you do this in two different ways? Name And Number 2 Write some Java code that asks the user for their name and a number. Your code must use a while loop to print the user's name the required number of times. Introduction To Java Objectives: To generate random numbers, and use them in our Java program. To use information provided by the user (via the keyboard) in our program. Description: Your task is to create a simple Maths Tutor program. First the user must choose if they want an Addition or Subtraction question (use A or S). This program will choose two random numbers (between 1 and 10 inclusive) and display a problem for the user to solve, e.g. 7+2 = The user can then enter the answer to the problem. If the user was correct, the program must display a nice message. If the user was wrong, program must tell them and display the correct answer. For subtraction questions, the smaller number must always be subtracted from the larger number (so that the answer can never be a negative number). Good coding practices are expected. Sample Output: Sample Output: MATHS TUTOR MATHS TUTOR What do you want to practice? (A)ddition or (S)ubtraction. A What do you want to practice? (A)ddition or (S)ubtraction. S 8+9 = 17 5-1 = 3 Correct! Wrong! The correct answer is 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
