contoh pemerograman ....suhu dan tarif pada warnet
package suhuaja;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double suhu,r,f,c;
char sk;
Scanner scan =new Scanner (System.in);
System.out.println ("suhu=");
suhu=scan.nextInt ();
System.out.println ("sk=");
sk=scan.next().charAt(0);
if (sk=='c');
f=9/5*suhu+32;
r=4/5*suhu;
System.out.println ("f="+f);
System.out.println ("r="+r);
if (sk=='f');
r=4/5*suhu;
c=9/5*suhu+32;
System.out.println ("c="+c);
System.out.println ("r="+r);
if (sk=='r');
c=9/5*suhu+32;
f=9/5*suhu+32;
System.out.println ("c="+c);
System.out.println ("f="+f);
}
}
------------------------------------------------------------------
package warnet;
import java.util.Scanner;
public class Main{
public static void main (String[]args){
double internet,game,total,totalbayar,diskon;
Scanner scan=new Scanner(System.in);
System.out.print("internet= ");
internet=scan.nextDouble();
System.out.print("game= ");
game=scan.nextDouble();
total=internet*50+game*75;
if (total<20000){
diskon=0.10*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
else
if ((total>=20000)&&(total<=30000)){
diskon=0.15*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
else
if
((total>=30000)&&(total<=40000)){
diskon=0.20*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
}
}
---------------------
penjelasanx tolong di bikin sendiri....
komenTAR ANDA
package suhuaja;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double suhu,r,f,c;
char sk;
Scanner scan =new Scanner (System.in);
System.out.println ("suhu=");
suhu=scan.nextInt ();
System.out.println ("sk=");
sk=scan.next().charAt(0);
if (sk=='c');
f=9/5*suhu+32;
r=4/5*suhu;
System.out.println ("f="+f);
System.out.println ("r="+r);
if (sk=='f');
r=4/5*suhu;
c=9/5*suhu+32;
System.out.println ("c="+c);
System.out.println ("r="+r);
if (sk=='r');
c=9/5*suhu+32;
f=9/5*suhu+32;
System.out.println ("c="+c);
System.out.println ("f="+f);
}
}
------------------------------------------------------------------
package warnet;
import java.util.Scanner;
public class Main{
public static void main (String[]args){
double internet,game,total,totalbayar,diskon;
Scanner scan=new Scanner(System.in);
System.out.print("internet= ");
internet=scan.nextDouble();
System.out.print("game= ");
game=scan.nextDouble();
total=internet*50+game*75;
if (total<20000){
diskon=0.10*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
else
if ((total>=20000)&&(total<=30000)){
diskon=0.15*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
else
if
((total>=30000)&&(total<=40000)){
diskon=0.20*total;
totalbayar=total-diskon;
System.out.print("total bayar = "+totalbayar);
}
}
}
---------------------
penjelasanx tolong di bikin sendiri....
komenTAR ANDA
Tidak ada komentar:
Posting Komentar