2e

Advanced Placement

Computer Science Lab

 

 

Math Class & Functions of a Circle or a Sphere

 

Introduction

 

In this lab we will continue to explore the Java the use of the Math class and the Decimal Format class.

 

 

 

 

 

 

Programming Assignment

 

 

 

Write a program to produce information regarding a circle and a sphere.  Prompt the user to input a diameter using the Keyboard class.  From the diamter calculate the circumference, area, inscribed area of a triangle, square and pentagon, the volume of a sphere and the surface area of a sphere.

 

Turn is a listing of your source code.  Source code should use proper formatting and be fully commented.  Also turn in a copy of your output.  This can be obtained by running the program and then using AltPrintScreen to copy the window of the output onto the clipboard.  Prior to using the Alt-Print Screen, change the background of the window to white and the text to black.  This can be done by clicking on the icon in the upper left hand corner of the output window and going to the properties item in the menu that appears. In the dialog box that appears just change background to white and text or foreground to black.  Then paste the contents of the clipboard into WordPad and print out the document.  In addition to the source code, the output, also turn in the answer to the questions listed below.