Skip to main content

Intercort Airways - java

IntercortAirways Tried my best to convert the code from c++ into java A program use to record the total weight that a flight can carry load. Then parcels are loaded into the flight until it full. There are 3 flights. In the end user can generate a report all flights and how much profits gained. I used Netbeans to create and run my code. Below are the print screens.

 

 Code:


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package intercortairways;

import java.util.Scanner;


/**
 *
 * @author Yvonne Kwarteng
 */
public class IntercortAirways {

    /**
     * @param args the command line arguments
     */
    //public variables
      public static int i=0, y=0, x=0;  //setup lools for element of parcels.

      public static int space1=0, space2=0, space3=0; // for calculating space left over
                // after entering parcels.

      public static int load_limit1;  // load_limit for flight no.1.
      public static int weight1; //reading of parcels for flight no.1.
      public static int totweight1;  // totalweight for flight no.1 initailised
      public static int total=0;
      public static float average_utilisation; // average for all the flights.
      public static float total_Revenue; // revenue for all the flighs.
      public int choice;  // reading for entering choice enter meun.

      //utilisations for the flights
      public static float flight_utilisation1,flight_utilisation2, flight_utilisation3;

      //revenue for the flights.
      public static float flight_revenue1, flight_revenue2, flight_revenue3;

      public static int load_limit2; //load_limit for flight no.2.
      public static int weight2;  // reading of parcels for flight no.2.
      public static int totweight2;  // totalweight for flight no.2 initailised.
      public static int load_limit3;  // load limit for flight no.3.
      public static int weight3;  // reading of parcels for flight no.3.
      public static  int totweight3; //total weight for flight no.3 initailised.

      public static int totweight, load_limit;
       //public menu();
    public static void main(String[] args) {
          
        // TODO code application logic here
          //call main 
          main();
         
    }
    
    //static methods are used to control the error of not static variable or static 
    //method not calling at main above
    public static void main(){
        
        Scanner reader = new Scanner(System.in);  // Reading from System.in
        System.out.println("Enter your choice: ");
        int n; 
    
        do
        {
        menu();
        
      
        n = reader.nextInt(); // Scans the next token of the input as an int.
        switch(n)
           
        {
        case 1: load_flight1();
            break;
        case 2: load_flight2();
            break;
        case 3: load_flight3();
            break;
        case 4: generate_report(totweight, load_limit);
        //case 4: generate_report();
            break;
        case 5: exit();
            break;
        default: System.out.println("Invalid menu choice");
                 System.out.println("press any key:");
           
        }  
        
        }while ((n!=1) && (n!=2) && (n!=3) && (n!=4) && (n!=5));

    }
   public static void menu(){
         
          System.out.println("=========================================");
        
          System.out.println("Y Y");
          
          System.out.println("Y INTERSCORT AIRWAYS LTD Y");
          
          System.out.println("Y Y");
          
          System.out.println("=========================================");
          
          System.out.println("Y Y");
          
          System.out.println("Y 1. Load_flight1 to Aircraft Y");
          
          System.out.println("Y Y");
          
          System.out.println("Y 2. load_flight2 to Aircraft Y");
          
         System.out.println("Y Y");
          
         System.out.println("Y 3. load_flight3 to Aircraft     Y");
          
          System.out.println("Y Y");
          
          System.out.println("Y 4. Generate_report       Y");
          
          System.out.println("Y Y");
          
          System.out.println("Y 5. Exit Y");
         
          System.out.println("Y Y");
          
          System.out.println("=========================================Y");
    }
   
            public static void load_flight1()
            {
            
            Scanner reader = new Scanner(System.in);  // Reading from System.in
            System.out.println("Enter flight no.1 load limit in kg: ");
           // for reading load limit
            //int s;//for reading parcel

            do
             
            {
            load_limit1 = reader.nextInt(); // Scans the next token of the input as an int.
             System.out.println("total limit1  " + load_limit1);
            System.out.println("\nEnter the weight of parcel no. " + i + ":");
            weight1 = reader.nextInt(); // Scans the next token of the input as an int.
            i=i++;

            totweight1=weight1+totweight1;  // calculations for total weight.

            // calculations for space left over after entering parcels.
            space1=load_limit1-totweight1;
            space1++;//1; // increment space left over.

            if (load_limit1-totweight1==0)
            {
                //go to main 
                main();
            }

            System.out.println("\nspace left is: " + space1 + "kg");
            //System.out.println("\nspace left is: " + space1++ + "kg");

            if(totweight1>load_limit1)
            {

            System.out.println("\n********Parcel rejected - refer to next flight.******");

            totweight1=totweight1-weight1; //weight is substruct from total weight.

            i=i-1;   // array of parcels is decrement from loop.}
            main();
            }

            if (weight1==0)
                main();
            weight1=weight1-1;  //decrement parcel.


            


            }


            while (weight1!=0);
            
            
             main();
            
            }//end of flight 1
            
         
            
            public static void load_flight2()
            {
         
            
            //clrscr ();
            int total;
            Scanner reader = new Scanner(System.in);  // Reading from System.in
            System.out.println("Enter flight no.2 load limit in kg: ");
           
            

           

            do
            {

            
            load_limit2 = reader.nextInt(); // Scans the next token of the input as an int.
            System.out.println("total limit1  " + load_limit2);
            System.out.println("\nEnter the weight of parcel no. " + y + ":");
            weight2 = reader.nextInt(); // Scans the next token of the input as an int.
            //for reading parcel weights
           
            y=y++;

            totweight2=weight2+totweight2; // calculation for total weight.

            // calculations for space left over after enter parcels.
            space2=load_limit2-totweight2; 
            space2++; //increment loop for space left.

            if (load_limit2-totweight2==0)
            {
                //go to main 
                main();
            }

            System.out.println("\nspace left is: " + space2 + "kg");
            //System.out.println("\nspace left is: " + space2++ + "kg");


            if(totweight2>load_limit2)
            {

            System.out.println("\n********Parcel rejected - refer to next flight.******");
            
            totweight2=totweight2 - weight2;  //weight is substruct from total weight.

            y=y-1;  // array of parcels is decrement from loop.
            main();
            }
            if (weight2==0)
             main();
            weight2=weight2-1;  //decrement reading parcel.
            


            }
            while (weight2!=0);
            
            
            main();
            //menu();
            
            
            }
            
            public static void load_flight3 ()
            {
        

            Scanner reader = new Scanner(System.in);  // Reading from System.in
            System.out.println("Enter flight no.3 load limit in kg: ");
            //int load_limit3;// for reading load limit
          
            do

            {
             load_limit3 = reader.nextInt(); // Scans the next token of the input as an int.
            System.out.println("total limit1  " + load_limit3);
            System.out.println("\nEnter the weight of parcel no. " + x + ":");
            weight3 = reader.nextInt(); // Scans the next token of the input as an int.
           

            x=x++;

            totweight3=weight3+totweight3; // calculations for total weight.

            // calculations for space left over after enter parcels.
            space3=load_limit3-totweight3;
            space3++;  //increment loop for space left.

            if (load_limit3-totweight3==0)
            {
                  //go to main
                main();
            }

            //System.out.println("\nspace left is:" + space3++ + "kg");
            System.out.println("\nspace left is:" + space3 + "kg");

            if(totweight3>load_limit3)
            {
            total=weight3;
            System.out.println("\n********Parcel not accepted.******");
            totweight3=totweight3-total; //weight is substruct from total weight.

            x=x-1;  // array of parcels is decrement from loop.
            main();
            }
            if (weight3==0)
               main();
            weight3=weight3-1;  //decrement reading parcel.

            


            }

            while (weight3!=0);
            
            //send data to generate report
            generate_report(totweight1,load_limit1);
            
            //send data to generate report
            generate_report(totweight2,load_limit2);
             
            //send data to generate report
            generate_report(totweight3,load_limit3);
           
            main();
            //menu();
            
            }
           
             public static void generate_report (int totweight,int load_limit)
             //public static void generate_report ()
             {
            


            System.out.println("*****************************************");
            System.out.println("\n*                                     *");
            System.out.println("\n* DAILY PAYLOAD CONTROL SYSTEMS       *");  
            System.out.println("\n*                       *");
            System.out.println("\n*                                     *");
            System.out.println("\n***************************************");

            if(totweight1==0 || load_limit1==0){
                 System.out.println("they are empty");
                 System.out.println(" total weight for flight 1 " + totweight1 + " load limit  flight 1 " + load_limit1);
             }
            //utilisation calculation for flight no.1.
            flight_utilisation1=(totweight1/load_limit1) * 100;

            System.out.println("print " + i);
            //calculation of revenue for flight no.1.
            flight_revenue1=(float) ((10 * i)+(1.50*totweight1));

            System.out.println("\n*******flight No.1 loading Completed,\n" + flight_utilisation1
            + "%Utilisation********\n");

            System.out.println("*******Revenue for" + i +"Parcels, £" + flight_revenue1
            + "**********\n");

            //utilisation calculation for flight no.2.
            flight_utilisation2=(totweight2/load_limit2) * 100;

            //calculation of revenue for flight no.2.
            flight_revenue2=(float) ((10 * y)+(1.50*totweight2));

            System.out.println("\n*******flight No.2 loading Completed,\n" + flight_utilisation2
            +"%Utilisation********\n");

            System.out.println("*******Revenue for " + y +" Parcels, £" + flight_revenue2
            + "**********\n");

             System.out.println(" total weight for flight 3 " + totweight3 + " load limit  flight 3 " + load_limit3);
            //utilisation calculation for flight no.3.
            flight_utilisation3=(totweight3/load_limit3) * 100;

            //calculation of revenue for flight no.3.
            flight_revenue3=(float) ((10 * x)+(1.50*totweight3));

            System.out.println("\n*******flight No.3 loading Completed,\n " +flight_utilisation3
            +" %Utilisation********\n");

            System.out.println("*******Revenue for " + x +" Parcels,£" +flight_revenue3
            + " **********\n");

            //calculations of average utilisation for all the flights. 
            average_utilisation=(flight_utilisation1+flight_utilisation2+flight_utilisation3)/3;

            //calculations of revenue of the day for all the flights.
            total_Revenue=flight_revenue1+flight_revenue2+flight_revenue3;

            System.out.println("\nThe average utilisation of all the flights are: " + " % "
            + average_utilisation);

            System.out.println("\nThe revenue for the day is: " + "£" + total_Revenue);


            System.out.println("\nPress any key to continue: ");
           
            menu();
            }
             public static void exit ()
             {
             

             System.out.println("The program is finish." + "Good bye!!");

             
             }

}
   
  

Comments

Popular posts from this blog

Working with Dropdownbox elements in Selenium WebDriver

How to select element from a Dropbox We are going to use Selenium webDriver and chrome driver to test this. In addition, this test was created on Mac.  I assume you have installed and setup java in your system path.  Also, install Eclipse for jee. 1. First let's take a look at a quick test case: Test case: TC_1. Register on http://automationpractice.com/index.php TC_1.1: Launch hope page -http://automationpractice.com/index.php TC_1.2 : Click on link ‘Sign in’ TC_1.3 : Under “Create Account” subheading, enter Email address in ‘Email address’ textfield TC_1.4 : Click on ‘Create an account’ button. —————————————————————————————— Test data: Email address: gorgeous12@hotmail.com http://automationpractice.com/index.php ---------------------------------------------------------------- Expected : http://automationpractice.com/index.php?controller=my-account ———————————------------ 2. Next, create a maven project in Eclipse 3....

Cypress UI Automation - part 1

Java to Cypress-JavaScript Automation Migration Introduction: Across Cancer Research UK engineering department, we currently use a Java automation framework for our User interface and API testing. The framework has evolved in the last 3 to 4 years and currently, we have 19 products/project, (running approximately 1350 test scenarios) using the framework to run the respective sanity/regression packs. The project/products extend across different technology stacks such as Drupal, Symphony, React JS, .Net, OBI and Siebel CRM.   The Quality Assurance (QA) test team are currently under the process to be transformed into a fully-fledged Quality Assurance function.   As part of this transformation, we would like to have a comprehensive, automated test suite that can be maintained by developers and testers. Furthermore, our front-end web development is moving into JavaScript, now is the right time to migrate our automation framework also from java into JavaScript. The introduction ...

Performance Testing

  Performance Testing As part of the Quality Assurance Test Approach, each tester has to implement performance testing within its product team. In this section of the project, I will be using Apache JMeter as the testing tool for the test approach. Apache JMeter is an open-source performance testing tool for load, stress and many more testing. Screenshot from: https://www.youtube.com/watch?v=817zU_bXh9Y&list=PLUDwpEzHYYLs33uFHeIJo-6eU92IoiMZ7 JMeter works by creating a request to a target server(website), the server then responds, saves responses, collects, calculate statistics, return results to request and then generate reports.