ช่วยเขียน อัลกอรึทึ่ม ของโปรแกรมจองต๋วเครื่องบินให้หน่อยคับ

กระทู้คำถาม
import java.io.*;         
public class java {             
    public static void main(String[] args) throws IOException, Exception {       
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Choose Destination");      
        System.out.println("1. Tokyo, Japan ");            
        System.out.println("2. Beijing, China ");         
        System.out.println("3. Doha, Qatar ");
        System.out.println("4. Belgium ");
        System.out.println("5. England ");
        System.out.println("6. united states ");         
        String strDestination = in.readLine();         
        System.out.println("Choose Seat Type ");             
        System.out.println("1. First Class ");                      
        System.out.println("2. Business Class ");                
        System.out.println("3. Economy Class ");               
        String strSeatType = in.readLine();         
       
        System.out.println("Choose Number of Seat ");         
        String strSeatNum = in.readLine();    

        int destination = Integer.parseInt(strDestination);       
        int seatType = Integer.parseInt(strSeatType);         
        int seatNum = Integer.parseInt(strSeatNum);        
        double price = 0;    
        String destinationName = "";   
        String seatTypeName = "";       

        switch(destination){    
            case 1:price=25000;destinationName="Tokyo";break;             
            case 2:price=20000;destinationName="Beijing";break;            
            case 3:price=30000;destinationName="Doha";break;
            case 4:price=40000;destinationName="Belgium";break;
            case 5:price=50000;destinationName="England";break;
            case 6:price=60000;destinationName="united states";break;
            default:System.exit(0);    
        }
        switch(seatType){    
            case 1:price=price*4;seatTypeName="First Class";break;        
            case 2:price=price*2;seatTypeName="Business Class";break;   
            case 3:seatTypeName="Economy Class";break;                      
            default:System.exit(0);         
   }
        price = price*seatNum;        
       System.out.println("::: Your Ticket Info ::");    
        System.out.println("From Bangkok To "+destinationName);    
        System.out.println("Seat    : "+seatTypeName);   
        System.out.println("Price  : "+price);
    }
}

นี่โค๊ดคับ

แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่