Minggu, 23 September 2018

AC

23 September 2018

Remote AC

Nama : Sherly Rosa Anggraeni
NRP :05111740000018
Kelas : PBO A

1. Main Program
Digunakan untuk main dari sebuah program
 /**  
  * REMOTE AC  
  *  
  * Sherly Rosa Anggraeni  
  * 05111740000018  
  * PBO-A  
  */  
 import java.util.Scanner;  
 public class main  
 {  
   public static void main (String args[]){  
     int suhu,fan,mode,display,power;  
     boolean swing;  
     suhu=0;  
     mode=0;  
     fan=0;  
     power=0;  
     swing=false;  
     System.out.println ("=====Remote OFF=====");  
     System.out.println ("====================");  
     Scanner m = new Scanner(System.in);  
       pengaturan menu=new pengaturan();    
       if (power==0){  
         menu.display();  
         while (true){  
       mode=m.nextInt();  
             if (mode==1) {  
             System.out.println ("=====Remote OFF=====");  
             System.out.println ("====================");  
             break;  
             }  
             if(mode==2){  
             menu.suhunaik();menu.display();  
            }  
             if(mode==3){  
             menu.suhuturun();menu.display();  
             }  
             if(mode==4){  
             menu.kec();menu.display();  
           }  
             if(mode==5){  
             menu.gerak();menu.display();  
             }  
           }}}}  

2. Program untuk pengendalian dari remote AC

 /**  
  * REMOTE AC  
  *  
  * Sherly Rosa Anggraeni  
  * 05111740000018  
  * PBO-A  
  */  
 import java.util.Scanner;  
 public class pengaturan  
 {  
   public boolean Power;  
   public int suhu;  
   public boolean swing;  
   public int kipas;  
   public pengaturan(){  
     Power = false;  
     suhu = 16;  
     swing = false;  
     kipas = 1;  
   }  
   public void Power1(){  
     if (Power){  
       Power=false;  
     }  
     else{  
       Power=true;}  
     }  
   public void gerak(){  
     if (swing){  
       swing =false;  
     }  
     else{  
       swing=true;  
     }  
     }  
   public void suhunaik(){  
     if (suhu<23){  
       suhu++;  
     } }  
   public void suhuturun(){  
     if(suhu>16){  
       suhu--;  
     }  
   }  
   public void kec()  
   {  
     if(kipas != 4)  
     {  
       kipas++;  
     }  
     else  
     {  
       kipas = 1;  
     }  
   }  
   public boolean Power()  
   {  
     return Power;  
   }  
   public int Suhu()  
   {  
     return suhu;  
   }  
   public int Kipas()  
   {  
     return kipas;  
   }  
   public boolean Swing()  
   {  
     return swing;  
   }  
   public void display(){   
     String DEGREE= "\u00b0";  
     System.out.println("=====Remote ON=======");  
     System.out.println("=====================");  
     System.out.println("Suhu="+suhu+DEGREE+"C");  
     System.out.println("Fan="+kipas);  
     System.out.println("Swing="+swing);  
     System.out.println("=====================");   
     System.out.println("1. Power");   
     System.out.println("2. Temperature Up");   
     System.out.println("3. Temperature Down");   
     System.out.println("4. Fan");   
     System.out.println("5. Swing");    
     System.out.println("=====================");   
   }  
 }  
Output
1. Tampilan awal
2. Temperatur Naik

3. Temperatur Turun

4. Fan

5. Swing

6. Power

Terima Kasih

Tidak ada komentar:

Posting Komentar