AreaOfTriangle - /* read the base */ double base =...

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

View Full Document Right Arrow Icon
/* * File: AreaOfTriangle.java * ------------------------- * This program prompts for the base and height * of a triangle and prints its area. * * Author: CS1MD3 */ import acm.program.*; public class AreaOfTriangle extends ConsoleProgram { public void run() {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* read the base */ double base = readDouble("Enter base: "); /* read the height */ double height = readDouble("Enter height: "); /* calculate and display the area */ double area = (base * height) / 2; println("Area = " + area); } }...
View Full Document

This note was uploaded on 10/27/2009 for the course COMP SCI 1MD3 taught by Professor Various during the Winter '07 term at McMaster University.

Ask a homework question - tutors are online