ShapeMaker - double height = inputSource.nextDouble();...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//****************************************************************************** // ShapeMaker.java Author: Lewis/Loftus // // Reads and stores the dimensions of various 3-D shapes from an input file. // Output is then created displaying pertinent information about the shapes. //****************************************************************************** / import java.io.*; import java.util.*; i public class ShapeMaker { //--------------------------------------------------------------------------- // Read the data from the input file and print the results. //--------------------------------------------------------------------------- public static void main(String[] args) { try { Scanner inputSource = new Scanner (new File("input.txt")); // Read the data from the input file while (inputSource.hasNext()) { String shapeType = inputSource.next(); if (shapeType.equalsIgnoreCase("prism")) { double width = inputSource.nextDouble(); double length = inputSource.nextDouble();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: double height = inputSource.nextDouble(); System.out.println(new Prism(width, length, height)); } else if (shapeType.equalsIgnoreCase("pentahedron")) { double width = inputSource.nextDouble(); double length = inputSource.nextDouble(); double height = inputSource.nextDouble(); System.out.println(new Pentahedron(width, length, height)); } else if (shapeType.equalsIgnoreCase("tetrahedron")) { double side = inputSource.nextDouble(); double height = inputSource.nextDouble(); System.out.println(new Tetrahedron(side, height)); } else if (shapeType.equalsIgnoreCase("sphere")) { double radius = inputSource.nextDouble(); System.out.println(new Sphere(radius)); } else if (shapeType.equalsIgnoreCase("cylinder")) { double radius = inputSource.nextDouble(); double height = inputSource.nextDouble(); System.out.println(new Cylinder(radius, height)); } } } catch (Exception except) { System.err.println(except); } } }...
View Full Document

Page1 / 2

ShapeMaker - double height = inputSource.nextDouble();...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online