import java.util.Scanner;
public class MyClass1 {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int smallest = 0, largest = 0, num, count = 0;
while (true){
System.out.println("Enter a number (-1 to quit): ");
num = scan.nextInt();
if (num == -1){
System.exit(0);
}
else if (num < 0){
System.out.println("Please enter a positive number!");
}
else{
if (num > largest){
largest = num;
}
if (num < smallest || count == 0){
smallest = num;
count++;
}
System.out.println("Smallest # so far: "+smallest);
System.out.println("Largest # so far: "+largest);
}
}
}
}
I hope this helps! If you have any other questions, I'll do my best to answer them.
Answer:
Point A: Always True
Point B: Sometimes false
Point C: Always False
Explanation:
In the given code snippet. Point A is the first statement within the While loop the statement System.out.println("Welcome to Java!"); will only be executed if the while condition evaluates to true.
At Point B, The statement count++ increases the value of the counter at every iteration, while it will be true for most occasions, at the last increament, this statement will be false that is at count=100, The condition will be false at this point just before program execution breaks out of the loop
Point C is outside of the loop, this happens when the given condition is no longer true.
Answer:
True
Explanation:
When the word windows is google, there are two basic interpretations: operating system and the windows in a home. This is the two dominant interpretation can be given to the word windows when queried.