//--------------------//
// Contoh Program Arirmatika Sederhana //
// Dengan 2 Inputan //
//-------------------//
import java.io.*;
public class InputanAngka
{
public static void main (String args[])
{
int C,D,E;
try
{
BufferedReader NilaiA=new BufferedReader (new InputStreamReader(System.in));
System.out.print("Masukan Nilai A = ");
String input1=NilaiA.readLine();
int A=Integer.parseInt(input1);
BufferedReader NilaiB=new BufferedReader (new InputStreamReader(System.in));
System.out.print("Masukan Nilai B = ");
String input2=NilaiB.readLine();
int B=Integer.parseInt(input2);
C = A + B;
D = A * B;
E = A - B;
System.out.println("");
System.out.println("Hasil A + B = "+C);
System.out.println("Hasil A x B = "+D);
System.out.println("Hasil A - B = "+E);
}
catch(IOException e)
{
e.printStackTrace();
}}}
Categories:
java