package average;
import javax.swing.JOptionPane;
/**
*
*/
public class Average {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int a,b,c;
int average;
String temp;
temp=JOptionPane.showInputDialog(null,"first number");
a=Integer.parseInt(temp);
temp=JOptionPane.showInputDialog(null,"second number");
b=Integer.parseInt(temp);
temp=JOptionPane.showInputDialog(null,"third number");
c=Integer.parseInt(temp);
average=(a+b+c)/3;
JOptionPane.showMessageDialog(null,"average is "+average);
}
package confirm;
import javax.swing.JOptionPane;
/**
*
*/
public class Confirm {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String input;
int a,b,c;
double average;
int repeat;
do
{
input=JOptionPane.showInputDialog(null,"enter score #1");
a=Integer.parseInt(input);
input=JOptionPane.showInputDialog(null,"enter score #2");
b=Integer.parseInt(input);
input=JOptionPane.showInputDialog(null,"enter score #3");
c=Integer.parseInt(input);
average=(a+b+c)/3.0;
JOptionPane.showMessageDialog(null, "the average is "+average);
repeat=JOptionPane.showConfirmDialog(null, "would you like to average another?","please Confirm",JOptionPane.YES_NO_CANCEL_OPTION);
}
while((repeat==JOptionPane.YES_NO_OPTION));
System.exit(0);
}
}
0 التعليقات:
إرسال تعليق