CS 107 - Introduction to Scientific Computation Homework #12 |
0. Preparatory Reading: You will benefit from reviewing the portions of Java we've covered in the CS 111 Java Summary.
1. Greetings: Create a Java program Greetings.java
that prompts
the user with "Your name? " to input their name, and prints "Hello, <name>!",
where "<name>" is replaced by their input name.
Example Transcript (input underlined):
Your name? Dolly
Hello, Dolly!
2. Division: Create a program Division.java that prompts the user to enter two integers (as shown below). The two integers a and b are then used to compute both the floating point and integer division results as follows.
Example Transcript (input underlined):
Please enter integer a: 9 Please enter integer b: 4 Floating point division: a/b = 2.250000 Integer division: a/b = 2 remainder 1
3. Circle: Define a class Circle (in Circle.java) with
4. Circle Test: Create a Java program CircleTest.java that prompts the user to input a double radius, constructs a Circle object from the previous exercise, and prints the double diameter, circumference, and area as shown below.
Note: You can calculate the square of radius
by using either
radius * radius
or Math.pow(radius, 2)
.
Example Transcript (input underlined):
Radius? 10 diameter = 20.000000 circumference = 62.831853 area = 314.159265