View the step-by-step solution to:

# CMS 167 Homework 2: Input and Arithmetic Operators Instructor: Due Date: Monday, September 12 Name:...

Answer the questions in the document, it's about Input and Arithmetic Operators

CMS 167 Homework 2: Input and ArithmeTc Operators Instructor: Due Date: Monday, September 12 Name: __________________________________________________________ Please sign the honor pledge below: On my honor, I have not given, nor received, nor witnessed any unauthorized assistance on this work. Your signature: ___________________________________ Part 1: Vocabulary ( 8 pts) 1. List Java’s 8 primiTve data types: Part 2: Declaring variables (4 pts. each) 2. Write a statement to declare a foa t variable named weight and give it the value 115.5; 3. Write a statement to assign the value 10 to the variable s, which has already been declared (see below). int s; 4. Write a statement to declare a char variable named leTerB and assign it the value B. 5. Write a statement to declare a boolean variable named isRaining and assign it the value true . Part 3: CalculaTons (4 pts. each ) 6. ____ will be the value of a aFer this statement : int a = 9 / 5; 7. ____ will be the value of b aFer this statement : int b = 9 % 5; 8. ____ will be the value of d aFer this statement: double d = 9 / 5; 9. ____ will be the value of c aFer this statement : int c = 12 / 6 * 3; 10. ____ will be the value of e aFer this statement : int e = 12 / ( 6 * 3 ); 11. ____ will be the value of f aFer this statement : int f = 6 + 6 / 2; 12. ____ will be the value of g aFer this statement: int g = ( 6 + 6 ) / 2;
13. ____ will be the value of h aFer this statement : double h = 7.0 / 3 ; 14. ____ will be the value of i aFer this statement: int i = (int) 7.0 / 5; 15. ____ will be the value of j aFer this statement: double j = (double) 7 / 5 ; 16. ____ will be the value of k aFer this statement: double k = (double) (7 / 5); 17. ____ will be the value of m aFer these statements: int m = 8; m++; 18. ____ will be the value of n aFer these statements: int n = 9; n--; 19. ____ will be the value of p aFer these statements: int p = 6; p += 6; 20. ____ will be the value of q aFer these statements: int q = 7; q *= 4; 21. ____ will be the value of r aFer these statements: int r = 12; r /= 6; Part 4. Write Some Code for User Input: 22. Write the Java statement to import the Scanner class. (2 pts.) 23. Write the Java statement to create (instanTate) a Scanner object named scan that will be used to read from the keyboard. (4 pts.) 24. Write three Java statements to prompt the user for the number of pets they have, read the value, and output the value the user entered. (6 pts)

CMS 167 Homework 2: Input and Arithmetic Operators
Instructor: Due Date: Monday, September 12
Name: __________________________________________________________
Please sign the honor pledge below:
On...

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents