{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

{[ snackBarMessage ]}

Ask a homework question - tutors are online