witchway915

Untitled

Aug 27th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. CS 209 - Assignment #3
  2. Chapter 2: Introduction to Java Applications - Read and study pp. 37-70
  3. Download the file assgn03.docx from the assignments folder – copy and paste your Java source code and sample output in the file, prefix your first initial and last name to the file name, e.g., twells_assgn3.docx, and upload your word processor solutions file by the due date. - Total points: 45
  4.  
  5. (15) 15. Write an application that asks the user to enter two integers, obtains them from the user, and prints their sum, product, difference, quotient (division), and remainder (modulus). Use the techniques shown in Fig. 2.7.
  6.  
  7.  
  8. (15) 26. Write an application that reads two integers, determines whether the first is a multiple of the second and prints the result. [Hint: Use the remainder operator.]
  9.  
  10.  
  11. (15) 28. In this chapter, we learned about integers and the type int. Java can also represent floating-point numbers that contain decimal points, such as 3.14159. Write an application that inputs from the user the radius of a circle as an integer and prints the circle’s diameter, circumference, and area using the floating-point value 3.14159 for π. Use the techniques shown in Fig. 2.7. [Note: You may also use the predefined constant Math.PI for the value of π. This constant is more precise than the value 3.14159. Class Math is defined in package java.lang. Classes in that package are imported automatically, so you do not need to import class Math to use it.] Use these formulas (r is the radius):
  12. diameter = 2r
  13. circumference = 2πr
  14. area = πr2
  15. Do not store the results of each calculation in a variable - specify each calculation as the value that will be output in a System.out.printf statement. Note that the values produced by the circumference and area calculations are floating-point numbers. Such values can be output with the format specifier %f in a System.out.printf statement. We learn more about floating-point numbers in Chapter 3.
Advertisement
Add Comment
Please, Sign In to add comment