SquareRoots - public static void main (String args) {...

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

View Full Document Right Arrow Icon
//******************************************************************** // SquareRoots.java // // Demonstrates the use of the JOptionPane class. //******************************************************************** import javax.swing.JOptionPane; class SquareRoots { //-------------------------------------------------------------------- // Finds and displays the square root of the value input by the user // Uses multiple dialog boxes for user interaction. //--------------------------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public static void main (String args) { String numStr, result; int num, again; do { numStr = JOptionPane.showInputDialog ("Enter an integer: "); num = Integer.parseInt(numStr); result = "The square root of that number is " + Math.sqrt(num); JOptionPane.showMessageDialog (null, result); again = JOptionPane.showConfirmDialog (null, "Do Another?"); } while (again == JOptionPane.YES_OPTION); } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online