Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote