Question 6 Which of the following verifies that the user enters a positive integ
ID: 3606804 • Letter: Q
Question
Question 6
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.nextInt();
} while (num > 0);
B.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num % 2 != 0);
C.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num <= 0);
D.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num == 0);
A.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num > 0);
B.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num % 2 != 0);
C.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num <= 0);
D.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num == 0);
Explanation / Answer
Answer: Option C
.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num <= 0);
this code will verify whether user enters ositive value or not
.
int num=0;
Scanner s = new Scanner(System.in);
do {
System.out.print("Enter a positive integer: ");
num = s.nextInt();
} while (num <= 0);
this code will verify whether user enters ositive value or not
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.