Membuat aplikasi pengaturan suhu AC, ini sederhana banget dan ribet mungkin, hehe
public class AturSuhu{
private static String A = "a";
private static String B = "b";
private static Integer ta,tb,tc,cs1,cs2,cs3;
private static Integer Suhu;
private static double jam;
public static void main (String args[])throws IOException
{
BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (System.in));
ta = 1;
tb = 2;
tc = 3;
cs1 = 3;
cs2 = 5;
cs3 = 7;
jam = 9.25;
System.out.println("Welcome in Electro Factory AC App \nBy Dewi Setiarini 1112091000037");
System.out.println("Date : January 7, 2013 \nTime : "+jam);
System.out.println("Menu :\n[a] Turn On \n[b] Turn Off");
System.out.print("Chose Menu : ");
String input1 = bufferedReader.readLine();
if (input1.equals(A))
{
System.out.println("Air Conditioner is On");
System.out.print("Insert Temperature that You Want : ");
Integer suhu = Integer.parseInt(bufferedReader.readLine());
System.out.println("The Current Temperature is "+suhu+" Degrees Celcius");
System.out.println("Comfort Sleep :\n[1] 3 Hours \n[2] 5 Hours \n[3] 7 Hours");
System.out.print("Chose Comfort Sleep's Time : ");
Integer input2 = Integer.parseInt(bufferedReader.readLine());
if (input2.equals(ta))
{
suhu=suhu+cs1/2+cs1/2;
System.out.println("Comfort Sleep is "+cs1+" Hours \nAC will be turn off in "+suhu+" Degrees Celcius at "+(jam+cs1)+"\nThank You, Enjoy Your Day :)");
}
else if(input2.equals(tb))
{
suhu=suhu+cs2/2+cs2/2;
System.out.println("Comfort Sleep is "+cs2+" Hours \nAC will be turn off in "+suhu+" Degrees Celcius at "+(jam+cs2)+"\nThank You, Enjoy Your Day :)");
}
else if(input2.equals(tc))
{
suhu=suhu+cs3/2+cs3/2;
System.out.println("Comfort Sleep is "+cs3+" Hours \nAC will be turn off in "+suhu+" Degrees Celcius at "+(jam+cs3)+"\nThank You, Enjoy Your Day :)");
}
else
{
System.out.println("Sorry, Your input is Wrong, You must insert 1, 2, or 3.");
System.exit(0);
}
}
else if(input1.equals(B))
{
System.out.println("Air Conditioner is Off, Thank You :)");
}
else
{
System.out.println("Sorry, Your input is Wrong, You must insert a or b.");
System.exit(0);
}
}
}
Selamat mencoba ^_^
Tidak ada komentar:
Posting Komentar