- #1
goku3240
- 4
- 0
Homework Statement
1) Given three already declared int variables, i , j , and temp , write some code that swaps the values in i and j . Use temp to hold the value of i and then assign j 's value to i . The original value of i , which was saved in temp , can now be assigned to j .
2) 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 .
3) 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 .
4)Given the variables isFullTimeStudent and age , write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true.
5) Write a conditional that assigns true to the variable fever if the variable temperature is greater than 98.6
6)
Write a conditional that decreases the variable shelfLife by 4 if the variable outsideTemperature is greater than 90 .
7)
Write a conditional that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000 .
8) Write a conditional that multiplies the values of the variable pay by one-and-a-half if the value of the boolean variable workedOvertime is true.
9) 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 .
10) 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 ( soldYesterday greater than soldToday ) or 1 .
11) 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.
12)
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the bool variables neutral , base , and acid :
false, false, true if pH is less than 7
false, true, false if pH is greater than 7
true, false, false if pH is equal to 7
13) 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
Homework Equations
the control structures if and else, true flase,
The Attempt at a Solution
the first i tried temp=i then j=temp and i switched up the variables but haven't good the right answer. all the other ones are the same i can't get the 1st few to understand the rest.