الموضوع: مساعدة Cpcs 202
عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 15-03-2015, 03:55 PM   #2

Hamsa }~

ولسوف يعطيك ربك فترضى ♥

الصورة الرمزية Hamsa }~

 
تاريخ التسجيل: May 2010
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: CS
نوع الدراسة: إنتظام
المستوى: متخرج
البلد: منطقة مكة المكرمة
الجنس: أنثى
المشاركات: 5,602
افتراضي

كود PHP:
import java.util.Scanner;


public class 
Assign2 {

    public static 
void main(String[] args) {
        
// TODO Auto-generated method stub

        //maximum number of tickets allowed for each employee
        
final int MAX_Tickets_No 4;
        
        
//The cost for each extra weight is 10 SAR per K.G. for local and 30 SAR per K.G. for abroad. 
        
final int Local_Extra_Weight 10;
        final 
int abroad_Extra_Weight 30;
        
        
/*
         * Write a Java program that allows the user to enter the airline name, 
         * destination (local or abroad), ticket type (guest, business and first class), 
         * passport number, name, number of adults, number of children, number of infants  
         * and other required information (See sample run) and then displays the information
         *  like the one shown in the following sample output. 
         */
        
        
Scanner sc = new Scanner(System.in);
        
//String Airline_Name = sc.nextLine();
        //String Des = sc.next();
        
        
System.out.println("------------------------------------------------\nWelcome to Airlines Office Agent System\n------------------------------------------------");
        
System.out.println("Press S for Saudi Airlines\nPress N for FlyNas Airlines\nPress O for Other Airlines\nEnter the Choice: ");
        
String Airline_Name_choice sc.next();
    
        if(
Airline_Name_choice.equals("s")||Airline_Name_choice.equals("S")||Airline_Name_choice.equals("n")||Airline_Name_choice.equals("N")
                ||
Airline_Name_choice.equals("o")||Airline_Name_choice.equals("O")){
            
System.out.println("Press 0 for Local Destination\nPress 1 for Abroad Destination\nEnter the Choice: ");
            
            
int Des_Type_choice sc.nextInt();
            if(
Des_Type_choice==0||Des_Type_choice==1){
                
System.out.println("Press G for Guest Class\nPress B for Business Class\nPress F for First Class\nEnter Choice: ");
                
String Ticket_Class_choice sc.next();
                
                if(
Ticket_Class_choice.equals("g")||Ticket_Class_choice.equals("G")||Ticket_Class_choice.equals("b")||Ticket_Class_choice.equals("B")
                        ||
Ticket_Class_choice.equals("f")||Ticket_Class_choice.equals("F")){
                    
System.out.println("Enter Passport Number: ");     int passport_no sc.nextInt();
                    
System.out.println("Enter Name: ");        String name sc.next();
                    
System.out.println("Enter Number of Adults: "); int adult_no sc.nextInt();
                    
                    if(
adult_no<=4){
                        
System.out.println("Enter Number of Children: "); int child_no sc.nextInt();
                    
                    if(
adult_no+child_no<=4){
                                
System.out.println("Enter Number of Infants: "); int infnant_no sc.nextInt(); 
                    
                    if(
adult_no+child_no+infnant_no<=4){
                        
System.out.println("Enter Total of Weights: ");
                        
int Total_Weight sc.nextInt();

                        
/*
                         * to calculate the totalcost for all tickets of employee based on the information
                         * in the table and from the above description.
                         */
                        
int Extra_weight_cost 0;
                        
int AdultCost 0,ChildCost 0,infantCost 0;
                        
int Adult_Allowed_Weight 0,Child_Allowed_Weight=0,infant_Allowed_Weight=0,AllowedWeight=0;
                        
double Extra_Weight,Extra_kg 0;

                        if(
Des_Type_choice==0)
                        {
                            if(
Airline_Name_choice.equals("s")||Airline_Name_choice.equals("S")){
                                
Extra_weight_cost Local_Extra_Weight;
                                if(
Ticket_Class_choice.equals("g")||Ticket_Class_choice.equals("G")){
                                
int Adult_Local_guest_ticket_Cost 200;
                                
AdultCost Adult_Local_guest_ticket_Cost;
                                
ChildCost AdultCost*50/100;
                                
infantCostAdultCost*10/100;
                                }
                                else if(
Ticket_Class_choice.equals("b")||Ticket_Class_choice.equals("B")){
                                
int Adult_Local_bussniss_ticket_Cost 500;
                                
AdultCost Adult_Local_bussniss_ticket_Cost;
                                
ChildCost AdultCost*60/100;
                                
infantCostAdultCost*30/100;
                                }
                                else{
                                
int Adult_Local_FirstClass_ticket_Cost 800;
                                
AdultCost Adult_Local_FirstClass_ticket_Cost;
                                
ChildCost AdultCost*80/100;
                                
infantCostAdultCost*50/100;
                                }
                                
Adult_Allowed_Weight =30;
                                
Child_Allowed_Weight=20;
                                
infant_Allowed_Weight=10;
                                
AllowedWeight adult_no*Adult_Allowed_Weight+child_no*Child_Allowed_Weight+infnant_no*infant_Allowed_Weight;
                            }
                            else if(
Airline_Name_choice.equals("f")||Airline_Name_choice.equals("F")){
                                
Extra_weight_cost Local_Extra_Weight;
                                if(
Ticket_Class_choice.equals("g")||Ticket_Class_choice.equals("G")){
                                
int Adult_Local_guest_ticket_Cost 150;
                                
AdultCost Adult_Local_guest_ticket_Cost;
                                
ChildCost AdultCost*70/100;
                                
infantCostAdultCost*20/100;
                                }
                                else if(
Ticket_Class_choice.equals("b")||Ticket_Class_choice.equals("B")){
                                
int Adult_Local_bussniss_ticket_Cost 400;
                                
AdultCost Adult_Local_bussniss_ticket_Cost;
                                
ChildCost AdultCost*80/100;
                                
infantCostAdultCost*40/100;
                                }
                                else{
                                
int Adult_Local_FirstClass_ticket_Cost 600;
                                
AdultCost Adult_Local_FirstClass_ticket_Cost;
                                
ChildCost AdultCost*85/100;
                                
infantCostAdultCost*50/100;
                                }
                                
Adult_Allowed_Weight =20;
                                
Child_Allowed_Weight=15;
                                
infant_Allowed_Weight=10;
                                
AllowedWeight adult_no*Adult_Allowed_Weight+child_no*Child_Allowed_Weight+infnant_no*infant_Allowed_Weight;
                            }
                        }
                        else
                        {
                            if(
Airline_Name_choice.equals("s")||Airline_Name_choice.equals("S")){
                                
Extra_weight_cost abroad_Extra_Weight;
                                
                                if(
Ticket_Class_choice.equals("g")||Ticket_Class_choice.equals("G")){
                                
int Adult_abroad_guest_ticket_Cost 2500;
                                
AdultCost Adult_abroad_guest_ticket_Cost;
                                
ChildCost AdultCost*50/100;
                                
infantCostAdultCost*10/100;}
                                else if(
Ticket_Class_choice.equals("b")||Ticket_Class_choice.equals("B")){
                                
int Adult_abroad_bussniss_ticket_Cost 4000;
                                
AdultCost Adult_abroad_bussniss_ticket_Cost;
                                
ChildCost AdultCost*60/100;
                                
infantCostAdultCost*30/100;}
                                else{
                                
int Adult_abroad_FirstClass_ticket_Cost 5000;
                                
AdultCost Adult_abroad_FirstClass_ticket_Cost;
                                
ChildCost AdultCost*80/100;
                                
infantCostAdultCost*50/100;}
                                
Adult_Allowed_Weight =50;
                                
Child_Allowed_Weight=30;
                                
infant_Allowed_Weight=20;
                                
AllowedWeight adult_no*Adult_Allowed_Weight+child_no*Child_Allowed_Weight+infnant_no*infant_Allowed_Weight;
                            }
                            
                            else if(
Airline_Name_choice.equals("f")||Airline_Name_choice.equals("F")){
                                
Extra_weight_cost abroad_Extra_Weight;
                                    if(
Ticket_Class_choice.equals("g")||Ticket_Class_choice.equals("G")){
                                    
int Adult_abroad_guest_ticket_Cost 2000;
                                    
AdultCost Adult_abroad_guest_ticket_Cost;
                                    
ChildCost AdultCost*70/100;
                                    
infantCostAdultCost*20/100;}
                                    else if(
Ticket_Class_choice.equals("b")||Ticket_Class_choice.equals("B")){
                                    
int Adult_abroad_bussniss_ticket_Cost 3500;
                                    
AdultCost Adult_abroad_bussniss_ticket_Cost;
                                    
ChildCost AdultCost*80/100;
                                    
infantCostAdultCost*40/100;}
                                    else{
                                    
int Adult_abroad_FirstClass_ticket_Cost 4500;
                                    
AdultCost Adult_abroad_FirstClass_ticket_Cost;
                                    
ChildCost AdultCost*85/100;
                                    
infantCostAdultCost*50/100;}
                                    
                                    
Adult_Allowed_Weight =30;
                                    
Child_Allowed_Weight=20;
                                    
infant_Allowed_Weight=15;
                                    
AllowedWeight adult_no*Adult_Allowed_Weight+child_no*Child_Allowed_Weight+infnant_no*infant_Allowed_Weight;
                                }

                        }
                        
                        
Extra_Weight= (Total_Weight-AllowedWeight)* Extra_weight_cost ;
                        if(
Airline_Name_choice.equals("o")||Airline_Name_choice.equals("O"))
                        {
                            
System.out.println("Enter Ticket Price for Adult: ");
                            
AdultCost =sc.nextInt();
                            
System.out.println("Enter the Extra of Weights: ");
                            
Extra_kg sc.nextInt();
                            
System.out.println("Enter Cost of Weight ExtarPer Kg: ");
                            
Extra_weight_cost sc.nextInt();
                            
Extra_WeightExtra_kgExtra_weight_cost ;
                        }
                        
                        
                        
double All_tickets_cost=(adult_no*AdultCost)+(child_no ChildCost)+ (infnant_noinfantCost);
                        
double Total_Cost=All_tickets_cost+Extra_Weight;
                        
System.out.println("==========================================================\nName:"+name
                                
+"\nPassport Number: "+passport_no+"\nTickets Cost: "+All_tickets_cost+"\nExtar Weight Cost : "
                                
+Extra_Weight+"\nTotal Cost : "+Total_Cost+"\n==========================================================");
                        
                         }
                    else
                        
System.out.println("The Maximum Number of Tickets allowed is FOUR");
                    }
                    else
                        
System.out.println("The Maximum Number of Tickets allowed is FOUR");
                }
                    else
                    
System.out.println("The Maximum Number of Tickets allowed is FOUR");
                
                }
                else
                    
System.out.println("Wrong Selection of Ticket Class!");
            }
            else
            
System.out.println("Wrong Selection of Destination Type!");
        }
        else
            
System.out.println("Wrong Selection of Airline Name!");
            
    }
    


 

توقيع Hamsa }~  

 

● سُبحان من يُربّت علينا حين يَصدُ كُل شَيء
و يَحنو عَلينا إذا قسى كُل شَيء ،
سُبحان من نحنُ بدونه لسنا بشَيء وبه كُل شَيء.* ♥

 

Hamsa }~ غير متواجد حالياً   رد مع اقتباس