Kamis, 15 Maret 2012

Hitung Nilai Resistor dengan Java

/*
nama file : Resistor.java
programer : elekomfireball.blogspot.com
deskripsi :
 -input Nilai 1
 -input Nilai 2
 -input Nilai 3
 -input Nilai 4
 -input Nilai 5
 -tampilkan hasil paralel dan seri
*/
import javax.swing.JOptionPane;
class Resistor
{
 public static void main(String[] args) 
 {
  //Deklarasikan variabel yg diperlukan
  String Nilai1String;
  String Nilai2String;
  String Nilai3String;
  String Nilai4String;
  String Nilai5String;

  int a;
  int b;
  int c;
  int d;
  int e;
  int seri;
  double paralel;
  
  Nilai1String = JOptionPane.showInputDialog("Masukkan Nilai1 : ");
  a = Integer.parseInt(Nilai1String); //ubah dari String ke Integer

  Nilai2String = JOptionPane.showInputDialog("Masukkan Nilai2 : ");
  b = Integer.parseInt(Nilai2String);

  Nilai3String = JOptionPane.showInputDialog("Masukkan Nilai3 : ");
  c = Integer.parseInt(Nilai3String);

  Nilai4String = JOptionPane.showInputDialog("Masukkan Nilai4 : ");
  d = Integer.parseInt(Nilai4String);

  Nilai5String = JOptionPane.showInputDialog("Masukkan Nilai5 : ");
  e = Integer.parseInt(Nilai5String);

  paralel = (a * b * c * d * e)/(a + b + c + d + e); 
  seri = a + b + c + d + e;

  JOptionPane.showMessageDialog(null, "Nilai Paralel = " + paralel + "\nNilai Seri = "  + seri);

 }
}

Tidak ada komentar:

Posting Komentar