Professional Documents
Culture Documents
/*
*
* Filename: "SumOfIntegersDoWhile.java"
* Created by 1,000_naymes for ICt 352
* Purpose: to add integers up to and including the value entered by a user
*/
import javax.swing.JOptionPane;
public class SumOfIntegersDoWhile
{
public static void main( String[] args )
{
/**************************************************************
declare and initialize variables
**************************************************************/
String openingMessage,
int1InputMessage,
int1String,
errorMessage,
outputMessage;
int int1 = 0, total = 0;
openingMessage = "Welcome to 1KN's program, which will ask you for a positive
integer and \ncompute the sum of all integers up to and including your number.";
JOptionPane.showMessageDialog( null, openingMessage );
int1InputMessage = "Please enter your positive integer: ";
int1String = JOptionPane.showInputDialog( int1InputMessage );
int1 = Integer.parseInt( int1String ); // converting string to double;
do
{
}
while( total < 1 );
System.exit(0);
} //end main
} //end class
Page 1
SumOfIntegersDoWhile
Page 2