/*========================================================================
programmer: Hendra Silaban
nama file : input data
tanggal : 29 nov 2011
deskripsi : -menginput data
-mencari nilai terbesar
========================================================================*/
import javax.swing.JOptionPane;
class ContohIf
{
public static void main(String[] args)
{
String nilaiAs;
int nilaiA;
String nilaiBs;
int nilaiB;
String nilaiCs;
int nilaiC;
nilaiAs = JOptionPane.showInputDialog("nilai A = " );
nilaiA = Integer.parseInt(nilaiAs);
nilaiBs = JOptionPane.showInputDialog("nilai B = ");
nilaiB = Integer.parseInt(nilaiBs);
nilaiCs = JOptionPane.showInputDialog("nilai C = ");
nilaiC = Integer.parseInt(nilaiCs);
if(nilaiA > nilaiB) //7 b5
{
if(nilaiA > nilaiC) // 7 c6
{
JOptionPane.showMessageDialog(null,"nilai A yang terbesar ");
}
else if(nilaiA < nilaiC) //c8
{
JOptionPane.showMessageDialog(null,"nilai C yang terbesar ");
}
else if(nilaiA == nilaiC)
{
JOptionPane.showMessageDialog(null,"nilai A dan C yang terbesar");
}
}
else if(nilaiB > nilaiC) //b=6 c=4
{
if(nilaiB > nilaiA) //b6 a=3
{
JOptionPane.showMessageDialog(null,"nilai B yang terbesar ");
}
else if(nilaiB < nilaiA) //b>c c=8
{
JOptionPane.showMessageDialog(null,"nilai A yang terbesar ");
}
else if(nilaiB == nilaiA)
{
JOptionPane.showMessageDialog(null,"nilai A dan B yang terbesar");
}
}
else if(nilaiC > nilaiA)
{
if(nilaiC > nilaiB)
{
JOptionPane.showMessageDialog(null,"nilai C yang terbesar");
}
else if(nilaiC < nilaiB)
{
JOptionPane.showMessageDialog(null,"nilai B yang terbesar");
}
else if(nilaiC == nilaiB)
{
JOptionPane.showMessageDialog(null,"nilai B dan C terbesar");
}
}
else if(nilaiA == nilaiB)
{
JOptionPane.showMessageDialog(null,"ketiga bilangan sama");
}
}
}
Tidak ada komentar:
Posting Komentar