In: Computer Science
Directions Create a class that computes the lift and drag of a rectangular planform wing. Lift can be calculated with the following equation: lift = Cl * A * 0.5 * rho * V2 Cl is the lift coefficient; it is dimensionless A is the area of the wing in m2 rho is the air density, in kg/m3 , for the altitude the wing is flying V is the velocity in m/s Drag can be calculated with the following equation: Drag = Cd * A * 0.5 * rho * V2 Cd is the drag coefficient; it is dimensionless The other variables are the same as the lift equation. Notes: Cl and Cd vary with the wing angle of attack. rho varies with altitude. A rectangular planform wing is 85% efficient when compared to the optimal elliptical wing.
import java.io.*;
import java.util.*;
public class LiftDrag {
public static void
calculateLift(){
Scanner sc =
new Scanner(System.in);
System.out.print("Enter lift coefficient:");
double ci =
Double.parseDouble(sc.nextLine());
System.out.print("Enter area:");
double ar =
Double.parseDouble(sc.nextLine());
System.out.print("Enter air density:");
double rho =
Double.parseDouble(sc.nextLine());
System.out.print("Enter velocity:");
double v =
Double.parseDouble(sc.nextLine());
double
lift = ci * ar * 0.5 * rho * v * v;
System.out.println("Lift:" + lift);
}
public static void
calculateDrag(){
Scanner sc =
new Scanner(System.in);
System.out.print("Enter lift coefficient:");
double cd =
Double.parseDouble(sc.nextLine());
System.out.print("Enter area:");
double ar =
Double.parseDouble(sc.nextLine());
System.out.print("Enter air density:");
double rho =
Double.parseDouble(sc.nextLine());
System.out.print("Enter velocity:");
double v =
Double.parseDouble(sc.nextLine());
double
drag = cd * ar * 0.5 * rho * v * v;
System.out.println("Drag:" + drag);
}
public static void main(String[]
args){
calculateLift();
calculateDrag();
}
}