CMPS 207: chapter 3 – Flashcards

Unlock all answers in this set

Unlock answers
question
if(outsideTemperature > 90){ shelfLife = shelfLife - 4; }
answer
Write a conditional that decreases the variable shelfLife by 4 if the variable outsideTemperature is greater than 90.
question
if(goodsSold > 500000){ bonus = 10000; }
answer
Write a conditional that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000.
question
if (age >= 65) seniorCitizens += 1; else nonSeniors +=1;
answer
Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise.
question
if (soldYesterday > soldToday) salesTrend = -1; else salesTrend = 1;
answer
Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison assigns salesTrend the value -1 or 1. -1 represents the case where soldYesterday is greater than soldToday; 1 represents the case where soldYesterday is not greater than soldToday.
question
if (gpa > 3.5) { deansList +=1; System.out.println(studentName); }
answer
Assume that the variables gpa, deansList and studentName, have been declared and initialized . Write a statement that adds 1 to deansList and prints studentName to standard out if gpa exceeds 3.5.
question
if (x > y) max = x; else max = y;
answer
Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.
question
min = x; if (y < min) min = y; if (z < min) min= z;
answer
Workbench PREV NEXT deadline: 02/12/2016 11:59 PM 20660 WORK AREA SOLUTIONS Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer variable min. Assume that all the variables have already been declared and that x, y, and z have been assigned values .
question
if ((modelYear >= 1995 && modelYear <= 1998) || (modelYear >=2004 && modelYear<=2006)) System.out.println("RECALL");
answer
Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. Given a variable modelYear write a statement that prints the message "RECALL" to standard output if the value of modelYear falls within those two ranges.
question
callsReceived = stdin.nextInt(); operatorsOnCall = stdin.nextInt(); if (operatorsOnCall == 0) System.out.print("INVALID"); else System.out.print(callsReceived/operatorsOnCall);
answer
NOTE: in mathematics, division by zero is undefined. So, in Java, division by zero is always an error. Given a int variable named callsReceived and another int variable named operatorsOnCall write the necessary code to read values into callsReceived and operatorsOnCall and print out the number of calls received per operator (integer division with truncation will do). HOWEVER: if any value read in is not valid input, just print the message "INVALID". ASSUME the availability of a variable , stdin, that references a Scanner object associated with standard input.
question
(x > y)
answer
Write an expression that evaluates to true if and only if the integer x is greater than the integer y.
question
(x%2 == 0)
answer
Write an expression that evaluates to true if the integer variable x contains an even value , and false if it contains an odd value
question
(x == 0)
answer
Write an expression that evaluates to true if and only if the value of the integer variable x is equal to zero.
question
(profits == losses)
answer
Write an expression that evaluates to true if and only if the variables profits and losses are exactly equal
question
c != ' '
answer
Given the char variable c, write an expression that is true if and only if the value of c is not the space character .
question
(index > lastIndex)
answer
Write an expression that evaluates to true if the value of index is greater than the value of lastIndex.
question
(hoursWorked > 40)
answer
Working overtime is defined as having worked more than 40 hours during the week. Given the variable hoursWorked, write an expression that evaluates to true if the employee worked overtime
question
(x>=y)
answer
Write an expression that evaluates to true if the value x is greater than or equal to y.
question
(numberOfMen>=numberOfWomen)
answer
Given the variables numberOfMen and numberOfWomen, write an expression that evaluates to true if the number of men is greater than or equal to the number of women
question
(average<60.0)
answer
Given a double variable called average, write an expression that is true if and only if the variable 's value is less than 60.0.
question
(grossPay<10000)
answer
Given an int variable grossPay, write an expression that evaluates to true if and only if the value of grossPay is less than 10,000.
question
(numberOfPrizes%numberOfParticipants == 0)
answer
Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants. Assume that numberOfParticipants is not zero.
question
(widthOfBox % widthOfBook != 0)
answer
Write an expression that evaluates to true if the value of the integer variable widthOfBox is not divisible by the value of the integer variable widthOfBook. Assume that widthOfBook is not zero. ("Not divisible" means has a remainder.)
question
(c == 'n')
answer
Assume that c is a char variable has been declared and already given a value . Write an expression whose value is true if and only if c is a newline character .
question
(c == ' ')
answer
Assume that c is a char variable has been declared and already given a value . Write an expression whose value is true if and only if c is a space character .
question
(c == 't')
answer
Assume that c is a char variable has been declared and already given a value . Write an expression whose value is true if and only if c is a tab character .
question
(c == ' ' || c== 'n' || c == 't')
answer
Assume that c is a char variable has been declared and already given a value . Write an expression whose value is true if and only if c is what is called a whitespace character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).
question
!(c == ' ' || c== 'n' || c == 't')
answer
Assume that c is a char variable has been declared and already given a value . Write an expression whose value is true if and only if c is NOT what is called a whitespace character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).
question
(x >= 0 && y<0)
answer
Given that the variables x and y have already been declared and assigned values , write an expression that evaluates to true if x is non-negative and y is negative.
question
(x>=0 || y<0)
answer
Given that the variables x and y have already been declared and assigned values , write an expression that evaluates to true if x is positive (including zero) or y is negative.
question
(temperature>90 && humidity < 10)
answer
Given the variables temperature and humidity, write an expression that evaluates to true if and only if the temperature is greater than 90 and the humidity is less than 10.
question
(yearsWithCompany < 5 && department !=99)
answer
Given the integer variables yearsWithCompany and department, write an expression that evaluates to true if yearsWithCompany is less than 5 and department is not equal to 99.
question
if (modelYear >= 1999 && modelYear <= 2002) { if (modelName == "Extravagant") System.out.print("RECALL"); }
answer
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002. Given a variable modelYear and a String modelName write a statement that prints the message "RECALL" to standard output if the values of modelYear and modelName match the recall details.
question
if (modelName == "Extravagant" && modelYear >= 1999 && modelYear <= 2002) recalled = true; else recalled = false;
answer
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002. A boolean variable named recalled has been declared . Given a variable modelYear and a String modelName write a statement that assigns true to recalled if the values of modelYear and modelName match the recall details and assigns false otherwise.
question
if (modelName == "Extravagant") { if (modelYear >= 1999 && modelYear <= 2002) System.out.println("RECALL"); } if (modelName == "Guzzler") { if (modelYear >= 2004 && modelYear <= 2007) System.out.println("RECALL"); }
answer
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line from model years 2004-2007. Given a variable modelYear and a String modelName write a statement that prints the message "RECALL" to standard output if the values of modelYear and modelName match the recall details.
question
if ((modelYear>=1999 && modelYear<=2002 && modelName=="Extravagant") || (modelYear>=2004 && modelYear<=2007 && modelName=="Guzzler")) { recalled=true; } else recalled=false;
answer
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line from model years 2004-2007. A boolean variable named recalled has been declared . Given a variable modelYear and a String modelName write a statement that assigns true to recalled if the values of modelYear and modelName match the recall details and assigns false otherwise.
question
if (modelYear >= 2001 && modelYear <= 2006) System.out.println("RECALL");
answer
Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prints the message "RECALL" to standard output if the value of modelYear falls within that range.
question
recalled = (modelYear >=2001 && modelYear <=2006);
answer
Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named recalled has been declared . Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the recall range and assigns false otherwise. Do not use an if statement in this exercise
question
if (modelYear > 2006 || modelYear < 2001) System.out.println("NO RECALL");
answer
Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prints the message "NO RECALL" to standard output if the value of modelYear DOES NOT fall within that range.
question
norecall = !(modelYear >=2001 && modelYear <=2006);
answer
Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A boolean variable named norecall has been declared . Given a variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT within the recall range and assigns false otherwise. Do not use an if statement in this exercise!
question
(x>='A' && x<='Z')
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is a upper-case letter.
question
(x>='a' && x<='z')
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is a lower-case letter.
question
(x>='0' && x<='9')
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is a decimal digit (0-9).
question
(x>=48 && x<=55)
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is an octal (Base 8) digit (0-7).
question
((x>='A' && x<='Z') || (x>='a' && x<='z'))
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is a letter.
question
((x>='A' && x<='Z') || (x>='a' && x<='z') || (x>='0' && x<='9'))
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is alphanumeric , that is either a letter or a decimal digit.
question
(( x>='0' && x<='9') || ( x>='a' && x<='f' ) || ( x>='A' && x<='F'))
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is an hexadecimal (Base 16) digit (0-9 plus A-F or a-f).
question
!(x>='A' && x<='Z')
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a upper-case letter.
question
!((x>='A' && x<='Z') || (x>='a' && x<='z'))
answer
Assume that x is a char variable has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a letter.
question
(s.equals("end"))
answer
Write an expression that evaluates to true if and only if the string variable s equals the string "end".
question
(s1.compareTo(s2)>0)
answer
Write an expression that evaluates to true if the value of the string variable s1 is greater than the value of string variable s2
question
(lastName.compareTo("Dexter")>0)
answer
Write an expression that evaluates to true if the value of variable lastName is greater than the string Dexter.
question
!s.equals("end")
answer
Write an expression that evaluates to true if and only if the string variable s does not equal the String literal end.
question
if (name1.compareTo(name2)>0) max = name1; else max = name2; if (name3.compareTo(max)>0) max = name3;
answer
Given the string variables name1, name2, and name3, write a fragment of code that assigns the largest value to the variable max (assume all three have already been declared and have been assigned values ).
question
if (name1.compareTo(name2)>0) first = name1; else first = name2;
answer
Given the String variables name1 and name2, write a fragment of code that assigns the larger of the two to the variable first (assume that all three are already declared and that name1 and name2 have been assigned values ). (NOTE: "larger " here means alphabetically larger , not "longer". Thus, "mouse" is larger than "elephant" because "mouse" comes later in the dictionary than "elephant"!)
question
(s.compareTo("mortgage")>0 && s.compareTo("mortuary")<0)
answer
Assume that s is a String . Write an expression whose value is true if and only if the value of s would come between "mortgage" and "mortuary" in the dictionary.
question
choice = stdin.next(); if (choice.equals("S")) { if (age <= 21) System.out.println("vegetable juice"); else System.out.println("cabernet"); } else if (choice.equals("T")) { if (age <= 21) System.out.println("cranberry juice"); else System.out.println("chardonnay"); } else if (choice.equals("B")) { if (age <= 21) System.out.println("soda"); else System.out.println("IPA"); } else System.out.println("invalid menu selection");
answer
Assume that an int variable age has been declared and already given a value . Assume further that the user has just been presented with the following menu: S: hangar steak, red potatoes, asparagus T: whole trout, long rice, brussel sprouts B: cheddar cheeseburger, steak fries, cole slaw (Yes, this menu really IS a menu!) Write some code that reads the String (S or T or B) that the user types in into a String variable choice that has already been declared and prints out a recommended accompanying drink as follows: if the value of age is 21 or lower, the recommendation is "vegetable juice" for steak, "cranberry juice" for trout, and "soda" for the burger. Otherwise, the recommendations are "cabernet", "chardonnay", and "IPA" for steak, trout, and burger respectively. Regardless of the value of age, your code should print "invalid menu selection" if the character read into choice was not S or T or B. ASSUME the availability of a variable , stdin, that references a Scanner object associated with standard input.
question
if (age < 18) minors += 1; else if (age >= 65) seniors += 1; else adults += 1;
answer
Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 through 64 and adds 1 to the variable seniors if age is 65 or older.
question
if (speed < 0) reverseDrivers += 1; else if (speed < 1) parkedDrivers += 1; else if (speed < 40) slowDrivers += 1; else if (speed <= 65) safeDrivers += 1; else speeders += 1;
answer
Write a statement that adds 1 to the variable reverseDrivers if the variable speed is less than 0,adds 1 to the variable parkedDrivers if the variable speed is less than 1,adds 1 to the variable slowDrivers if the variable speed is less than 40,adds 1 to the variable safeDrivers if the variable speed is less than or equal to 65, and otherwise adds 1 to the variable speeders.
question
if (score1 > score2) { System.out.print("player1 wins"); player1Wins += 1; player2Losses += 1; } else if (score2 > score1) { System.out.print("player2 wins"); player1Losses += 1; player2Wins += 1; } else { System.out.print("tie"); tieCount += 1; }
answer
Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message "player1 wins" is printed to standard out. When score2 exceeds score1, the message "player2 wins" is printed to standard out. In each case, the variables player1Wins,, player1Losses, player2Wins, and player2Losses,, are incremented when appropriate. Finally, in the event of a tie, the message "tie" is printed and the variable tieCount is incremented .
question
if (pH < 7) { neutral = 0; base = 0; acid = 1; } else if (pH > 7) { neutral = 0; base = 1; acid = 0; } else { neutral = 1; base = 0; acid = 0; }
answer
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variables neutral, base, and acid: 0,0,1 if pH is less than 7 0,1,0 if pH is greater than 7 1,0,0 if pH is equal to 7
question
freeBooks = 0; if (isPremiumCustomer == true) { if (nbooksPurchased >= 5) freeBooks = 1; if (nbooksPurchased >= 8) freeBooks = 2; } else if (isPremiumCustomer == false) { if (nbooksPurchased >= 7) freeBooks = 1; if (nbooksPurchased >= 12) freeBooks = 2; }
answer
Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books. Write a statement that assigns freeBooks the appropriate value based on the values of the boolean variable isPremiumCustomer and the int variable nbooksPurchased.
question
(x >= 5 ? x : -x)
answer
Write an expression using the conditional operator (? :) that compares the value of the variable x to 5 and results in: x if x is greater than or equal to 5 -x if x is less than 5
question
(x < y ? y : x)
answer
Write an expression using the conditional operator (? :) that compares the values of the variables x and y. The result (that is the value ) of this expression should be the value of the larger of the two variables .
question
(x1 < x2 ? x2 : x1) - (y1 < y2 ? y1 : y2)
answer
Four int variables , x1, x2, y1, and y2, have been declared and been given values . Write an expression whose value is the difference between the larger of x1 and x2 and the smaller of y1 and y2.
question
(month == 1) ? "jan" : (month == 2) ? "feb" : (month == 3) ? "mar" : (month == 4) ? "apr" : (month == 5) ? "may" : (month == 6) ? "jun" : (month == 7) ? "jul" : (month == 8) ? "aug" : (month == 9) ? "sep" : (month == 10) ? "oct" : (month == 11) ? "nov" : "dec"
answer
Assume that month is an int variable whose value is 1 or 2 or 3 or 5 ... or 11 or 12. Write an expression whose value is "jan" or "feb" or "mar" or "apr" or "may" or "jun" or "jul" or "aug" or "sep" or "oct" or "nov" or "dec" based on the value of month. (So, if the value of month were 4 then the value of the expression would be "apr".).
question
(credits < 30) ? "freshman" : (credits >= 30 && credits < 60) ?"sophomore" : (credits >= 60 && credits < 90) ? "junior" : "senior"
answer
Assume that credits is an int variable whose value is 0 or positive. Write an expression whose value is "freshman" or "sophomore" or "junior" or "senior" based on the value of credits. In particular: if the value of credits is less than 30 the expression 's value is "freshman"; 30-59 would be a "sophomore", 60-89 would be "junior" and 90 or more would be a "senior".
question
true
answer
Write a literal representing the true value .
question
false
answer
Write a literal representing the false value .
question
boolean isACustomer;
answer
Declare a variable isACustomer suitable for representing a true or false value .
question
boolean hasPassedTest = true;
answer
Declare a variable hasPassedTest, and initialize it to true .
question
if (temperature > 98.6) fever = true;
answer
Write a conditional that assigns the boolean value true to the variable fever if the variable temperature is greater than 98.6.
question
if (workedOvertime == true) pay = pay * 1.5;
answer
Write a conditional that multiplies the value of the variable pay by one-and-a-half if the value of the boolean variable workedOvertime is true .
question
(workedOvertime == true)
answer
Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true .
question
if (temperature > 98.6) fever = true; else fever = false;
answer
Write an if/else statement that assigns true to the variable fever if the variable temperature is greater than 98.6; otherwise it assigns false to fever.
question
if ((n%2==0 && n>2)||(n<=0)) possibleCandidate=false; else possibleCandidate=true;
answer
Assign to the boolean variable 'possibleCandidate' the value false if the int variable 'n' is even and greater than 2, or if the variable 'n' is less than or equal to 0; otherwise, assign true to 'possibleCandidate'. Assume 'possibleCandidate' and 'n' are already declared and 'n' assigned a value .
question
(age < 19 || isFullTimeStudent == true)
answer
Given the variables isFullTimeStudent and age, write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true .
question
(isAMember==false)
answer
Write an expression that evaluates to true if and only if value of the boolean variable isAMember is false .
question
if (onOffSwitch==false) onOffSwitch=true; else onOffSwitch=false;
answer
Write a statement that toggles the value of onOffSwitch. That is, if onOffSwitch is false , its value is changed to true ; if onOffSwitch is true , its value is changed to false .
question
if (isIsosceles == true) { isoCount += 1; triangleCount += 1; polygonCount += 1; }
answer
Assume that isIsosceles is a boolean variable , and that the variables isoCount,triangleCount, and polygonCount have all been declared and initialized . Write a statement that adds 1 to each of these count variables (isoCount,triangleCount, andpolygonCount) if isIsosceles is true .
question
if (hoursWorked > 40) workedOvertime= true; else workedOvertime = false;
answer
Assume that a boolean variable workedOvertime has been declared , and that another variable , hoursWorked has been declared and initialized . Write a statement that assigns the value true to workedOvertime if hoursWorked is greater than 40 and false otherwise.
question
if (numberOfSides == 4) isQuadrilateral = true; else isQuadrilateral = false;
answer
Assume that a boolean variable isQuadrilateral has been declared , and that another variable , numberOfSides has been declared and initialized . Write a statement that assigns the value true if numberOfSides is exactly 4 and false otherwise.
question
(isEmpty==false && (numberOfCredits == 1 || numberOfCredits == 3))
answer
Given two variables , isEmpty of type boolean , indicating whether a class roster is empty or not, and numberOfCredits of type integer , containing the number of credits for a class , write an expression that evaluates to true if the class roster is not empty and the class is one or three credits.
question
(isEmpty==true || numberOfCredits==3)
answer
Given two variables , isEmpty of type boolean , indicating whether a class roster is empty or not, and numberOfCredits of type int , containing the number of credits for a class , write an expression that evaluates to true if the class roster is empty or the class is exactly three credits.
question
(isEmpty==false && numberOfCredits>2)
answer
Given two variables , isEmpty of type boolean , indicating whether a class roster is empty or not, and numberOfCredits of type int , containing the number of credits for a class , write an expression that evaluates to true if the class roster is not empty and the class is more than two credits
question
norecall = !((modelYear >=1995 && modelYear <=1998) || (modelYear >= 2004 && modelYear <= 2006));
answer
Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. A boolean variable named recalled has been declared . Given a variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT fall within the two recall ranges and assigns false otherwise. Do not use an if statement in this exercise!
question
recalled = ((modelYear >=1995 && modelYear <=1998) || (modelYear >= 2004 && modelYear <= 2006));
answer
Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. A boolean variable named recalled has been declared . Given a variable modelYear write a statement that assigns true to recalled if the value of modelYear falls within the two recall ranges and assigns false otherwise. Do not use an if statement in this exercise!
question
switch ( response ) { case 'y': System.out.println( "Your request is being processed"); break; case 'n': System.out.println( "Thank you anyway for your consideration"); break; case 'h': System.out.println( "Sorry, no help is currently available"); break; default: System.out.println( "Invalid entry; please try again"); }
answer
Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y, the message Your request is being processed is printed if response is n, the message Thank you anyway for your consideration is printed if response is h, the message Sorry, no help is currently available is printed for any other value of response, the message Invalid entry; please try again is printed
question
switch (age) { case 0: case 1: System.out.println("ineligible"); break; case 2: System.out.println("toddler"); break; case 3: case 4: case 5: System.out.println("early childhood"); break; case 6: case 7: System.out.println("young reader"); break; case 8: case 9: case 10: System.out.println("elementary"); break; case 11: case 12: System.out.println("middle"); break; case 13: System.out.println("impossible"); break; case 14: case 15: case 16: System.out.println("high school"); break; case 17: case 18: System.out.println("scholar"); break; default: System.out.println("ineligible"); }
answer
In the Happy Valley School System, children are classified by age as follows: less than 2, ineligible 2, toddler 3-5, early childhood 6-7, young reader 8-10, elementary 11 and 12, middle 13, impossible 14-16, high school 17-18, scholar greater than 18, ineligible Given an int variable age, write a switch statement that prints out, on a line by itself, the appropriate label from the above list based on age.
question
switch (status) { case 200: System.out.println("OK (fulfilled)"); break; case 403: System.out.println("forbidden"); break; case 404: System.out.println("not found"); break; case 500: System.out.println("server error"); break; }
answer
HTTP is the protocol that governs communications between web servers and web clients (i.e. browsers). Part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. Some of the codes and their meanings are listed below: 200, OK (fulfilled) 403, forbidden 404, not found 500, server error Given an int variable status, write a switch statement that prints out, on a line by itself, the appropriate label from the above list based on status.
question
response = stdin.nextInt(); if (response == 1 || response == 2) { yesCount++; System.out.print("YES WAS RECORDED"); } else if (response == 3 || response == 4) { noCount++; System.out.print("NO WAS RECORDED"); } else System.out.print("INVALID");
answer
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. ASSUME the availability of a variable , stdin, that references a Scanner object associated with standard input.
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New