Need help with writing a Java Script for this lab: Thank you! Hint Recall that a
ID: 2247203 • Letter: N
Question
Need help with writing a Java Script for this lab:
Thank you!
Hint Recall that a class has the following structure: public class PowerLoading //fields // constructor (s) // accessors and mutators I/ general methods Your class should have only one field that will contain vMax. The constructor should initialize vMax. vMax may have an accessor and mutator. One general method for each type of aircraft. Second Hint Each of the power loading calculations should be a separate method. Recall that Java method headers have the following general form: visibilitySpecifier returnType methodName( parameterList) The method for fixed gear normal design could be as follows: public double fixedGearNormal() return calculation hereExplanation / Answer
Hi
I calculate simple with full decimal values if you need to round off values then uncomment lines in methods
//double factor = 1e10; // = 1 * 10^10 = 10000000000.
//power = Math.round(power * factor)/factor;
add in all other methods
1. PowerLoading Class
public class PowerLoading {
private double vMax;
public PowerLoading(double aMax) {
this.vMax = aMax;
}
public double getvMax() {
return vMax;
}
public void setvMax(double vMax) {
this.vMax = vMax;
}
// Fixed Gear Normal
public double fixedGearNormal() {
double power = 0;
double temp = 215 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.61);
// round of values to 10 decimal point
// double factor = 1e10; // = 1 * 10^10 = 10000000000.
// power = Math.round(power * factor)/factor;
return power;
}
// Retract Gear Normal
public double retractGearNormal() {
double power = 0;
double temp = 276 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.65);
return power;
}
// Fixed Gear Smooth
public double fixedGearSmooth() {
double power = 0;
double temp = 248 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.61);
return power;
}
// Retract Gear Smooth
public double retractGearSmooth() {
double power = 0;
double temp = 680 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.79);
return power;
}
// Acrobatic gear
public double acrobatic() {
double power = 0;
double temp = 172 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.61);
return power;
}
// RagWings
public double ragWings() {
double power = 0;
double temp = 511 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.75);
return power;
}
// Ultralights
public double Ultralights() {
double power = 0;
double temp = 325 * vMax;
// calculate power of temp
power = Math.pow(temp, -0.75);
return power;
}
}
2. Driver Class
public class PowerDriver {
public static void main(String[] args) {
PowerLoading pl = new PowerLoading(350);
System.out.println("fixed gear Normal: "+pl.fixedGearNormal());
System.out.println("Retract gear Normal: "+pl.retractGearNormal());
System.out.println("fixed gear Smooth: "+pl.fixedGearSmooth());
System.out.println("Retract gear Smooth :"+pl.retractGearSmooth());
System.out.println("Acrobatic :"+pl.acrobatic());
System.out.println("RagWings :"+pl.ragWings());
System.out.println("Ultralights :"+pl.Ultralights());
}
}
Let me know if any change
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.