SphereApp

SphereApp - Sphere s2 = new Sphere(u1);...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; public class SphereApp{ public static void main(String[] arqs){ Sphere s1 = new Sphere(); s1.setDiameter(2.75); System.out.println("Diameter: " + s1.getDiameter()); System.out.println("Volume: " + s1.volume()); System.out.println("Area: " + s1.area()); S Scanner userinput = new Scanner(System.in); System.out.println("Enter the diameter"); double u1 = userinput.nextDouble();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sphere s2 = new Sphere(u1); System.out.println(s2); System.out.println("Area: " + s2.area()); S Sphere s3 = new Sphere(Math.random()*12 + 5); System.out.println(s3); System.out.println("Area: " + s3.area()); S double avg = (s2.area()) + (s3.area()) / (2); System.out.println("The average area of Sphere 2 and Sphere 3 is " + avg); }} }...
View Full Document

This document was uploaded on 02/11/2011.

Ask a homework question - tutors are online