SumProduct - { String numString, result; int num1, num2,...

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

View Full Document Right Arrow Icon
//******************************************************************** // SumProduct.java Author: Lewis/Loftus // // Solution to Programming Project 5.8 // //******************************************************************** / import javax.swing.JOptionPane; i public class SumProduct { //----------------------------------------------------------------- // Uses dialog boxes to prompt a user for two integers. Displays // the sum and the product of the integers. Allows the user to // choose to process more pairs of numbers //----------------------------------------------------------------- public static void main (String args[])
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { String numString, result; int num1, num2, again; do { numString = JOptionPane.showInputDialog("Enter an integer: "); num1 = Integer.parseInt(numString); numString = JOptionPane.showInputDialog("Enter another integer: "); num2 = Integer.parseInt(numString); result = "You entered " + num1 + " and " + num2; result += "\nThe sum of these numbers is " + (num1 + num2); result += "\nThe product of these numbers is " + (num1 * num2); JOptionPane.showMessageDialog(null, result); again = JOptionPane.showConfirmDialog(null, "Another?"); } while (again == JOptionPane.YES_OPTION); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online