public class TriangleEgW1 - perimeter = a + b + c; String...

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

View Full Document Right Arrow Icon
Import javax.swing.JOptionPane; Import java.util.*; Import java.text.*; public class TriangleEgW1 { public static void main(String[] args) { double a, b, c; String inputString; //input from a dialog box double perimeter; StringTokenizer st; DecimalFormat fmt = new DecimalFormat (“0.00”); inputString = JOptionPane.showInputDialog (“Input the sides of a triangle ” + “on one line”); st = new StringTokenizer (inputString); a = Double.parseDouble (st.nextToken()); b = Double.parseDouble (st.nextToken()); c = Double.parseDouble (st.nextToken());
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: perimeter = a + b + c; String outputString; outputString = “sides are “ + fmt.format(a) + “, “ + fmt.format(b) + “, “ + fmt.format(c) ) + “\nPerimeter is “ + fmt.format(perimeter)); // Display the results. JOptionPane.showMessageDialog(null, “sides are “ + fmt.format(a) + “, “ + fmt.format(b) + “, “ + fmt.format(c) ) + “\nPerimeter is “ + fmt.format(perimeter)); JOptionPane.showMessageDialog(null, outputString); // End the program. System,exit (0); } }...
View Full Document

This note was uploaded on 05/25/2010 for the course CS 1050 taught by Professor Tucker during the Spring '10 term at Metropolitan State College of Denver.

Ask a homework question - tutors are online