Answer:
This is an infinite loop.
Explanation:
The while loop while never end since the last statement inside the while loop will continue to decrement the value of num by 1 and the condition num < 9 will always be true.
So either change the condition of the while loop like: num > -9
or start incrementing the variable num in the last statement of the while loop like:
num = num + 1
Note: Don't make both changes at the same time.
Visit: gotit-pro.com for fastest, top-notch and impeccable homework and exams help in a range of subjects and ace your academics.
Thanks and Best Regards: Your Friendly Study Co-Pilot
Search for it in the start menu. Once you find it, right click and press "Pin to taskbar."
Answer:
import java.util.Scanner;
public class TestClock {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
System.out.print("Enter favorite color:");
String word1 = in.next();
System.out.print("Enter pet's name:");
String word2 = in.next();
System.out.print("Enter a number:");
int num = in.nextInt();
System.out.println("you entered: "+word1+" "+word2+" "+num);
}
}
Explanation:
Using Java Programming language
- Import the Scanner class
- create an object of the scanner class
- Prompt user to enter the values for the variables (word1, word2, num)
- Use String concatenation in System.out.println to display the output as required by the question.
Software to damage computers