Ziggs
2012-08-29 13:57:38 UTC
Declare two int variables firstInt and secondInt with the values 37 and 5. What do you think are going to be the results of the following? Display the results using five System.out.println statements.
My guess System.out.println
firstInt+secondInt
firstInt-secondInt
firstInt*secondInt
firstInt/secondInt
firstInt%secondInt
Declare a double variable called myDouble and assign it the value 98.7. Using an assignment operator, divide the variable by 7.5 and store it in the variable myDouble. Using a System.out.println statement, display the value of myDouble.
Declare an int variable called myInt and assign it the value 3.14. What error message is displayed when you try to compile this line. Make a change to the declaration so that it assigns a legal int value to the variable. Write down this line.
Declare a named constant of type int named numberOfStates. (Note: the public static final line must be outside of function main().) On the next line assign it a value of 50. What is the error message? How must you correct this?
Declare an int variable myInt and assign it the value 31+4*5-26/8%2. What do you think the value is going to be (write this down)? Display the value using a System.out.println statement. What is the value?
Declare a double variable called myDouble and assign it the value 1.0. Divide the variable by 1
3751 (a random number I picked) and then by 3.14. Then multiply the variable by 13.3751 and then by 3.14. Using a System.out.println statement, display the value of myDouble. What is its value? Try other random floating point values with numbers after the decimal point.
Declare five int variables called score1, score2, score3, score4, and score5 and assign them the values 72, 81 88, 98, and 99. Declare a variable called total and add the values of the five variables into the variable total. Declare an int variable called count and assign it the value 5. Declare a double variable called average. Divide total by count and assign its value to average. What is its value? Change the division so that it returns a double rather than an int. Write down the changed line.
Rewrite 8 so that rather than assigning values to the five int variables, the user inputs five values.
yes this is a homework question and yes I am in desperate need! I have not bought my book yet because I cannot afford one yet!!! But desperately need help with this program! I can do all my other assignments but having trouble figuring this out! Please only post if your going to help me or show me how its done! Thank you!