Belajar java pra uts pak indra
import javax.swing.*;
public class BiodataMahasiswa{
public static void main(String args[])
{
String thmsk;
String jurusan;
String jenjang;
String cetak;
String nama = JOptionPane.showInputDialog("Masukkan nama anda!");
String nim = JOptionPane.showInputDialog("Masukkan nim anda!");
thmsk = nim.substring(0,2);
thmsk = "20" + thmsk;
jurusan = nim.substring(2,4);
if (jurusan .equals("11") )
jurusan = " Tekhnik Informatika";
else if (jurusan .equals("12") )
jurusan = " Sistem Informasi";
else if (jurusan .equals("13") )
jurusan = " Sistem Komputer";
jenjang = nim.substring(4,5);
if (jenjang.equals("5"))
jenjang = " Strata 1";
else if (jenjang.equals("3"))
jenjang = " Diploma 3";
JOptionPane.showMessageDialog( null,"Nim :"+nim +"\n"+ "Nama :"+ nama +"\n" +"thnmasuk :"+thmsk +"\n"+ "jurusan :"+ jurusan +"\n"+ "Jenjang :"+ jenjang,"Hasil",JOptionPane.INFORMATION_MESSAGE );
}
}
2.PARKING
import java.util.Scanner;
public class Parking{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
String platnomor;
double jamdatang;
double jamkeluar;
double lamaparkir;
double biaya;
System.out.print("Masukan Nomor Plat Nomor Anda: ");
platnomor=input.next();
System.out.print("Masukan Jam Datang: ");
jamdatang=input.nextDouble();
System.out.print("Masukan Jam Keluar: ");
jamkeluar=input.nextDouble();
lamaparkir=(jamkeluar-jamdatang)/10000;
biaya=lamaparkir*1000;
System.out.println("Tarif Parkir per Jam = Rp. 1000,00");
System.out.println("Lama parkir: "+lamaparkir);
System.out.println("Total yang Harus Dibayar: "+biaya);
}
}
3.PALINDROME
import java.io.*;
public class palindrom{
public static void main(String args[])
{
StringBuffer sb;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println ("Masukkan Kata:");
String kata = input.readLine();
sb = new StringBuffer(kata);
if((sb.toString()).equals((sb.reverse()).toString()))
{
System.out.println ("\n\nPalindrome");
}
else
{
System.out.println ("\n\nBukan Palindrome");
}
}
}
4.LUAS SEGITIGA
import java.util.Scanner;
import java.io.*;
public class LuasSegitiga {
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
int alas;
int sisi1;
int sisi2;
int sum;
System.out.print("Masukkan alas : ");
alas = input.nextInt();
System.out.print("Masukkan sisi1 : ");
sisi1 = input.nextInt();
System.out.println ("masukan sisi2 :");
sisi2=input.nextInt();
sum =(alas * 0.5) * (sisi1 * sisi2);
System.out.println("segitiga : "+sum);
if (alas==sisi1==sisi2)
System.out.println ("segitiga sama sisi");
else if (sisi1==sisi2)
System.out.println ("segitiga sama kaki");
else
System.out.println ("segitiga sembarang");
}
}
Tidak ada komentar:
Posting Komentar