Question: Hi, could you code a different solution using different Java control constructs and/or a different arrangement of Java control constructs as per below: /** *

Hi, could you code a different solution using different Java control constructs and/or a different arrangement of Java control constructs as per below:

/** * This is a simple weight calculator for a Cessna 172 aircraft. Based on user inputs, * it will tell you if your airplane is within it's takeoff weight limits or if it exceeds the take off weight limit. * If the airplane is not within take-off limits, the user will be prompted to enter how many LBS will they be reducing. * One the (weight they reduce - the total weight of the airplane) is within take off limits, the program will end.

*/

import java.util.Scanner;

public class Discussion03 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

//General message

System.out.println("ALL THE WEIGHT AND THE FUEL IS MEASURED IN LBS");

// Prompt the user to enter Empty Weight

System.out.println("Basic Empty Weight (Use the data pertaining to your airplane as it is presently equipped Includes unusable fuel and full oil): ");

double emptywt = input.nextDouble();

// Prompt the user to enter weight of usable fuel

System.out.println("Usable Fuel (At 6 Lbs./ Gal.): ");

double fuel = input.nextDouble();

//Prompt the user to enter Pilot's and front Passenger's weight

System.out.println("Pilot and Front Passenger: ");

double ppfront = input.nextDouble();

// Prompt the user to enter rear passenger's weight

System.out.println("Rear Passengers: ");

double rpass = input.nextDouble();

// Prompt the user to enter weight of the baggage in baggage area 1

System.out.println("Baggage Area 1: ");

double bay1 = input.nextDouble();

// Prompt the user to enter weight of the baggage in baggage area 2

System.out.println("Baggage Area 2: ");

double bay2 = input.nextDouble();

// Calculate ramp weight double rampwt = emptywt + fuel + ppfront + rpass + bay1 + bay2;

System.out.println("Ramp Weight: " + rampwt);

// Prompt the user to enter amount of fuel burned during engine start, taxi, and run up

System.out.println("Fuel allowance for engine start, taxi and run up: ");

double fallow = input.nextDouble();

// Calculate Total Take Off weight

double totalwt = rampwt - fallow;

System.out.println("Ramp Weight: " + totalwt);

{

{

//Display message if the airplane is within take off weight limits.

if ((totalwt <= 2550))

System.out.println("Within 'Take Off' weight limits");

//Code to run then airplane is outside its take off weight limits.

while (totalwt > 2550) {

System.out.print("Reduce weight in LBS: ");

double number = input.nextInt();

double y = ((totalwt) - (number));

if (y <= 2550) {

System.out.println("Weight is with limits now!");

break;

// This ends the loop

} else {

if (y > 2550) {

System.out.println("STILL OVERWEIGHT: Enter total weight you are reducing");

}

}

}

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!