Jumat, 27 November 2009

Surce-Code Average

package average;

import javax.swing.JOptionPane;

public class Main {

public static void main( String args[] ){
String firstNumber;
String secondNumber;
String threeNumber;
String fourNumber;
String fiveNumber;
int number1;
int number2;
int number3;
int number4;
int number5;
int jumlah;
int average;

firstNumber =
JOptionPane.showInputDialog( "Masukkan nilai Pertama" );

secondNumber =
JOptionPane.showInputDialog( "Masukkan nilai Kedua" );

threeNumber =
JOptionPane.showInputDialog( "Masukkan nilai ketiga" );

fourNumber =
JOptionPane.showInputDialog( "Masukkan nilai keempat" );

fiveNumber =
JOptionPane.showInputDialog( "Masukkan nilai kelima" );

number1 = Integer.parseInt( firstNumber );
number2 = Integer.parseInt( secondNumber );
number3 = Integer.parseInt( threeNumber );
number4 = Integer.parseInt( fourNumber );
number5 = Integer.parseInt( fiveNumber );

jumlah = number1 + number2+number3+number4+number5;
average =(number1 + number2+number3+number4+number5)/5;

JOptionPane.showMessageDialog(null, "Jumlahnya adalah " + jumlah, "Results", JOptionPane.WARNING_MESSAGE );
JOptionPane.showMessageDialog(null, "Rata-ratanya adalah " + average, "Results", JOptionPane.WARNING_MESSAGE );
System.exit( 0 );
}
}

Tidak ada komentar:

Posting Komentar