Which of the following verifies that the user enters a positive integer value? A
ID: 3851998 • Letter: W
Question
Which of the following verifies that the user enters a positive integer value? A. int num = 0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "): num = s.nextlnt(): } while (num = = 0): B. int num=0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "): num = s.nextlnt(): } while (num % 2 ! = 0): C. int num=0: Scanner s = new Scanner(System.in): do { System.out.print("Enter a positive integer: "): num = s.nextlnt(): } while (num 0);Explanation / Answer
Answer:
From the below options The user enters a positive integer value
Answer is "D"
int num==0;
Scanner s=new Scanner(System.in);
do{
System.out.print("Enter a positive integer:");
num=s/nextint();
}while (num > 0);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.