6.4k views
3 votes
Given a int variable named yesCount and another int variable named noCount and an int variable named response write the necessary code to read a value into into response and then carry out the following: if the value typed in is a 1 or a 2 then increment yesCount and print out "YES WAS RECORDED" if the value typed in is a 3 or an 4 then increment noCount and print out "NO WAS RECORDED" If the input is invalid just print the message "INVALID" and do nothing else.

1 Answer

1 vote

Answer:

Step-by-step explanation:

RESPONSE = stdin.nextInt();

if (RESPONSE== 1 || RESPONSE == 2){

YESCOUNT++;

System.out.println("YES WAS RECORDED");

}

else if (RESPONSE == 3 || RESPONSE== 4){

NOCOUNT++;

System.out.println("NO WAS RECORDED");

}

else

System.out.println("INVALID");

User Alleyne
by
4.1k points