# Homework Help: Codelab excercise 2- computer programming part 1

1. Feb 15, 2010

### goku3240

1. The problem statement, all variables and given/known data

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

2. Relevant equations

the control structures if and else, true flase,

3. The attempt at a solution

the first i tried temp=i then j=temp and i switched up the variables but havent good the right answer. all the other ones are the same i cant get the 1st few to understand the rest.

2. Feb 16, 2010

### Staff: Mentor

Same comment as in your other thread: Per the forum rules, you need to make an effort at this yourself before getting help.

3. Feb 16, 2010

### goku3240

KK thx I just joined today, and I just read the rules. So i will try it out but will i reiceve help with the difficult ones?

4. Feb 16, 2010

### Staff: Mentor

Post 1 problem at a time, not 10 or a dozen, and show that you are making a serious attempt at writing the code for it. If you're still stuck, someone will steer you in the right direction.