Program Java: Membuat Menu Rumus Matematika

Diposting pada 1.285 views
Lagi iseng-iseng bantu temen, heheh bikin program java buat rumus matematika.
contoh rumusnya seperti ini :
1. y=2x+5
2. y=2a(x-2)
3. y=-1/x2-1
4. c2=a2+b2
x2,c2,b2,a2 mksdnya x,c,b,a pangkat 2

Screen shot program:

Download program di sini

Coding:

import java.io.*;

public class InputanMenuRumus
{
public static void main(String[] args) throws Exception
{
BufferedReader kata = new BufferedReader(new InputStreamReader(System.in));

int pil;

do
{

System.out.println("MENU :");
System.out.println(" 1.Rumus y=2x+5 ");
System.out.println(" 2.Rumus y=2a(x-2) ");
System.out.println(" 3.Rumus y=-1/x2 – 1 ");
System.out.println(" 4.Rumus c2=a2+b2 ");
System.out.println(" 5.Exit ");
System.out.println("PILIHAN [1-5] : ");

pil=Integer.parseInt(kata.readLine());

}while(pil <1 || pil>5);

if (pil == 1)
{
System.out.println("Rumus y=2x+5");
//membuat turunan class untuk input dari user
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan nilai x: ");
int x = Integer.parseInt(dataIn.readLine());
int total =((2*x)+5);
System.out.print("Rumus y=2x+5= ");
System.out.println(total);
}
if (pil == 2)
{
System.out.println("Rumus y=2a(x-2)");
//membuat turunan class untuk input dari user
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan nilai x: ");
int x = Integer.parseInt(dataIn.readLine());
System.out.print("Masukan nilai a: ");
int a = Integer.parseInt(dataIn.readLine());
int total =((2*a)*(x-2));
System.out.print("Rumus y = 2a(x-2)= ");
System.out.println(total);
}
if (pil == 3)
{
System.out.println("Rumus y=-1/x2 – 1");
//membuat turunan class untuk input dari user
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan nilai x: ");
double x = Double.parseDouble(dataIn.readLine());
double k = (x*x);
double total =(((-1)/k)-1);
System.out.print("Rumus y=-1/x2 – 1= ");
System.out.println(total);
}
if (pil == 4)
{
System.out.println("Rumus c2=a2+b2");
//membuat turunan class untuk input dari user
BufferedReader dataIn=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Masukan nilai a: ");
int a = Integer.parseInt(dataIn.readLine());
System.out.print("Masukan nilai b: ");
int b = Integer.parseInt(dataIn.readLine());
int total =((a*a)+(b*b));
System.out.println("");
System.out.print("Rumus c2=a2+b2= ");
System.out.println(total);
}
else if (pil == 5)
{
System.out.println("Anda Memilih keluar ");
}
}

}

10 thoughts on “Program Java: Membuat Menu Rumus Matematika

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *