CSI205                                                             Assignment #1                        Assigned:         09/08/11

                                                                                                                        Due:                 09/15/11

                     

Write a Java Application that displays the height of a rainbow from a given distance.

 

Because of the way light is refracted by water droplets, the angle between the level

of your eye and the top of the rainbow is always the same. If you know the distance

to the rainbow, you can multiply it by the tangent of that angle to find the height of the rainbow.

The magic angle is 42.33333 degrees. Java works in radians, however, so you have to convert the

angle to radians with this formula:

 

Radians = degrees x   pi / 180

 

pi = 3.14159265

 

If you multiply the tangent by the distance to the rainbow, you get the height of the rainbow.

 

You should write an application that:

 

-          Prompts the user "Please Input the Distance to Rainbow"

-          Accepts a single real number from the keyboard, the distance

-          Outputs "The rainbows height from XX feet is YY feet"

(where XX is the distance and YY is the height)

 

Notes:

 

-Include Comments in your code and format your program neatly. Remember to include your name and

Student ID# in your comments

 

-The tan() method is included in the Math class, which is  part of the java.lang package. Therefore, no import

statement is needed to use this class. The method is invoked with the statement Math.tan()

 

-All variables you use for mathematical computations should be of type double

 

-The name of the file which you save your application into should be named  prog1.java

 

 The command to submit your assignment is

 

turnin-csi205 –c csi205 –s section1 –p prog1