CodeLab 10.30.06

CodeLab 10.30.06 - CodeLab: 10.30.06 Given the variables...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CodeLab : 10.30.06 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. 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. Given the variables isFullTimeStudent and age, write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true. age < 19 || isFullTimeStudent == true Write an expression that evaluates to true if and only if value of the boolean variable isAMember is false. isAMember == false 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. if (age < 18) minors++; adults++; else if (age >= 65) seniors++; 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 if (pH < 7) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
neutral = 0; base = 0; acid = 1; } else if (pH > 7) { neutral = 0; base = 1; acid = 0; } else { neutral = 1; base = 0; acid = 0; } 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 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"); } Write an expression using the conditional operator (?:) that compares the value of the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/29/2008 for the course CS 302 taught by Professor Willbenton during the Fall '07 term at Wisconsin.

Page1 / 7

CodeLab 10.30.06 - CodeLab: 10.30.06 Given the variables...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online