Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

which of the following best describes live stream

Answered: 1 week ago

Question

How appropriate would it be to conduct additional research?

Answered: 1 week ago

Question

MAT135 Page Answered: 1 week ago

Answered: 1 week ago