Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Lab \" View for Wind Correction Angle\" Need help with the following the ja

ID: 3587757 • Letter: J

Question

Java Lab "View for Wind Correction Angle"

Need help with the following the java code, please help me! Thank you!!

import java.awt.*;
import javax.swing.*;

public class E6Bview extends JFrame
{
public E6Bview()
{
super( "E6B" );

JTabbedPane e6bTab = new JTabbedPane();

// add tabs to e6bTab
e6bTab.addTab( "Density Altitude", null, new DensityAltView(), "");

add( e6bTab );

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,200);
setVisible(true);
}

public static void main(String[] args)
{
E6Bview e6bv = new E6Bview();
}
}

-----------------------------------------------------------------------------------------------------------------------------------------

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DensityAltView extends JPanel
{
private JTextField tfStationPressure;
private JTextField tfStationTempF;
private JTextField tfAirfieldAlt;
private JButton bCalc;
private JLabel lblDensityAlt;

public DensityAltView()
{
setLayout( new GridLayout( 4,2, 2,2 ) );

add( new JLabel("Station Pressure (inHg)") );
tfStationPressure = new JTextField("29.95");
add( tfStationPressure );

add( new JLabel("Station Temperature (F)") );
tfStationTempF = new JTextField("59");
add( tfStationTempF );

add( new JLabel("Elevation (ft)") );
tfAirfieldAlt = new JTextField("0");
add( tfAirfieldAlt );

bCalc = new JButton( "Density Altitude" );
add( bCalc );
// connect button to handler here


lblDensityAlt = new JLabel( "unknown" );
lblDensityAlt.setBorder( BorderFactory.createLineBorder(Color.black) );
add( lblDensityAlt );
}// constuctor end


}// end class




/*

   private class ButtonHandler implements ActionListener
   {
   public void actionPerformed(ActionEvent ae)
   {
   double sp = Double.parseDouble( tfStationPressure.getText() );
   double st = Double.parseDouble( tfStationTempF.getText() );
   double aa = Double.parseDouble( tfAirfieldAlt.getText() );
  
   E6B e6b = new E6B(sp,st,aa, 0,0,0,0,0, 0, 0);
  
   String das = Double.toString( e6b.densityAltitude() );
  
   lblDensityAlt.setText( das );
   }
   } // end class buttonHandler
  
*/

------------------------------------------------------------------------------------------------------------------------------------------------------------------

E6B Lab Code

import java.util.Scanner;

public class E6BFlightComputer {

// instance variables

private double P;

private double T;

private double DA;

private int altitude;

private int IAS;

private double TAS;

private double w;

private double d;

private double Vw;

private double a;

private double Vg;

public E6BFlightComputer()

{

this.P = 0;

this.T = 0;

this.altitude = 0;

this.IAS = 0;

this.w = 0;

this.d = 0;

this.Vw = 0;

}

// parameterized constructor

public E6BFlightComputer(double p, double t, int altitude, int iAS, double w, double d, double vw)

{

P = p;

T = t;

this.altitude = altitude;

IAS = iAS;

this.w = w;

this.d = d;

Vw = vw;

calcDensityAltitude();

calcTrueAirSpeed();

calcWindCorrectionAngle();

calcGroundSpeed();

}

// getters and setters

public double getStationPressure() {

return P;

}

public double getStationTemperature() {

return T;

}

public double getDensityAltitude() {

return DA;

}

public int getAltitude() {

return altitude;

}

public int getIAS() {

return IAS;

}

public double getWindDirection() {

return w;

}

public double getDesiredCourse() {

return d;

}

public double getTrueAirSpeed() {

return TAS;

}

public double getWindSpeed() {

return Vw;

}

public double getGroundSpeed()

{

return this.Vg;

}

public void setStationPressureP(double p) {

P = p;

}

public void setStationTemperature(double t) {

T = t;

}

public void setAltitude(int altitude) {

this.altitude = altitude;

}

public void setIAS(int iAS) {

IAS = iAS;

}

public void setWindDirection(double w) {

this.w = w;

}

public void setDesiredCouse(double d) {

this.d = d;

}

public void setWindSpeed(double vw) {

Vw = vw;

}

private void calcDensityAltitude()

{

double temp = Math.pow( (17.326*this.P / (459.67 + this.T) ), 0.235 );

this.DA = 145442.16*(1 - temp);

}

private void calcTrueAirSpeed()

{

this.TAS = (double)this.IAS+(this.altitude/1000)*0.02*this.IAS;

}

private void calcWindCorrectionAngle()

{

this.a = Math.asin(this.Vw*Math.sin(this.w - this.d) / this.TAS);

}

private void calcGroundSpeed()

{

double d = Math.toRadians(this.d);

double w = Math.toRadians(this.w);

double a = Math.toRadians(this.a);

double temp = 2*this.TAS*this.Vw*Math.cos( d - w + a);

this.Vg = Math.sqrt( (this.TAS*this.TAS) + (this.Vw*this.Vw) - temp);

}

// main method

public static void main(String args[])

{

double stationP, stationT, airportE;

int aircraftA;

int Iairspeed;

double desiredC, windD, windS;

Scanner kybd = new Scanner(System.in);

System.out.print("Enter the station Pressure in Hg: ");

stationP = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the station Temperature in F: ");

stationT = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the aircraft altitude in feet: ");

aircraftA = Integer.parseInt(kybd.nextLine());

System.out.print("Enter the indicated airspeed in knots: ");

Iairspeed = Integer.parseInt(kybd.nextLine());

System.out.print("Enter the desired course: ");

desiredC = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the wind direction: ");

windD = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the wind speed in knots: ");

windS = Double.parseDouble(kybd.nextLine());

E6BFlightComputer FC = new E6BFlightComputer(stationP, stationT, aircraftA, Iairspeed,

windD, desiredC, windS);

System.out.printf("Density Altitude: .2f ", FC.getDensityAltitude());

System.out.println("True air speed: " + FC.getTrueAirSpeed());

System.out.println("Wind correction angle: " + FC.getTrueAirSpeed());

System.out.println("Ground speed: " + FC.getGroundSpeed());

}

}

Explanation / Answer

the code has modified

import java.awt.*;
import javax.swing.*;

public class E6Bview extends JFrame
{
public E6Bview()
{
super( "E6B" );

JTabbedPane e6bTab = new JTabbedPane();

// add tabs to e6bTab
e6bTab.addTab( "Density Altitude", null, new DensityAltView(), "");

add( e6bTab );

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300,200);
setVisible(true);
}

public static void main(String[] args)
{
E6Bview e6bv = new E6Bview();
}
}
-----------------------------------------------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DensityAltView extends JPanel
{
private JTextField tfStationPressure;
private JTextField tfStationTempF;
private JTextField tfAirfieldAlt;
private JButton bCalc;
private JLabel lblDensityAlt;

public DensityAltView()
{
setLayout( new GridLayout( 4,2, 2,2 ) );

add( new JLabel("Station Pressure (inHg)") );
tfStationPressure = new JTextField("29.95");
add( tfStationPressure );

add( new JLabel("Station Temperature (F)") );
tfStationTempF = new JTextField("59");
add( tfStationTempF );

add( new JLabel("Elevation (ft)") );
tfAirfieldAlt = new JTextField("0");
add( tfAirfieldAlt );

bCalc = new JButton( "Density Altitude" );
add( bCalc );
// connect button to handler here


lblDensityAlt = new JLabel( "unknown" );
lblDensityAlt.setBorder( BorderFactory.createLineBorder(Color.black) );
add( lblDensityAlt );
}// constuctor end


}// end class


/*

private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
double sp = Double.parseDouble( tfStationPressure.getText() );
double st = Double.parseDouble( tfStationTempF.getText() );
double aa = Double.parseDouble( tfAirfieldAlt.getText() );
  
E6B e6b = new E6B(sp,st,aa, 0,0,0,0,0, 0, 0);
  
String das = Double.toString( e6b.densityAltitude() );
  
lblDensityAlt.setText( das );
}
} // end class buttonHandler
  
*/



------------------------------------------------------------------------------------------------------------------------------------------------------------------
E6B Lab Code
import java.util.Scanner;

public class E6BFlightComputer {

// instance variables

private double P;

private double T;

private double DA;

private int altitude;

private int IAS;

private double TAS;

private double w;

private double d;

private double Vw;

private double a;

private double Vg;

public E6BFlightComputer()

{

this.P = 0;

this.T = 0;

this.altitude = 0;

this.IAS = 0;

this.w = 0;

this.d = 0;

this.Vw = 0;

}

// parameterized constructor

public E6BFlightComputer(double p, double t, int altitude, int iAS, double w, double d, double vw)

{

P = p;

T = t;

this.altitude = altitude;

IAS = iAS;

this.w = w;

this.d = d;

Vw = vw;

calcDensityAltitude();

calcTrueAirSpeed();

calcWindCorrectionAngle();

calcGroundSpeed();

}

// getters and setters

public double getStationPressure() {

return P;

}

public double getStationTemperature() {

return T;

}

public double getDensityAltitude() {

return DA;

}

public int getAltitude() {

return altitude;

}

public int getIAS() {

return IAS;

}

public double getWindDirection() {

return w;

}

public double getDesiredCourse() {

return d;

}

public double getTrueAirSpeed() {

return TAS;

}

public double getWindSpeed() {

return Vw;

}

public double getGroundSpeed()

{

return this.Vg;

}

public void setStationPressureP(double p) {

P = p;

}

public void setStationTemperature(double t) {

T = t;

}

public void setAltitude(int altitude) {

this.altitude = altitude;

}

public void setIAS(int iAS) {

IAS = iAS;

}

public void setWindDirection(double w) {

this.w = w;

}

public void setDesiredCouse(double d) {

this.d = d;

}

public void setWindSpeed(double vw) {

Vw = vw;

}

private void calcDensityAltitude()

{

double temp = Math.pow( (17.326*this.P / (459.67 + this.T) ), 0.235 );

this.DA = 145442.16*(1 - temp);

}

private void calcTrueAirSpeed()

{

this.TAS = (double)this.IAS+(this.altitude/1000)*0.02*this.IAS;

}

private void calcWindCorrectionAngle()

{

this.a = Math.asin(this.Vw*Math.sin(this.w - this.d) / this.TAS);

}

private void calcGroundSpeed()

{

double d = Math.toRadians(this.d);

double w = Math.toRadians(this.w);

double a = Math.toRadians(this.a);

double temp = 2*this.TAS*this.Vw*Math.cos( d - w + a);

this.Vg = Math.sqrt( (this.TAS*this.TAS) + (this.Vw*this.Vw) - temp);

}

// main method

public static void main(String args[])

{

double stationP, stationT, airportE;

int aircraftA;

int Iairspeed;

double desiredC, windD, windS;

Scanner kybd = new Scanner(System.in);

System.out.print("Enter the station Pressure in Hg: ");

stationP = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the station Temperature in F: ");

stationT = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the aircraft altitude in feet: ");

aircraftA = Integer.parseInt(kybd.nextLine());

System.out.print("Enter the indicated airspeed in knots: ");

Iairspeed = Integer.parseInt(kybd.nextLine());

System.out.print("Enter the desired course: ");

desiredC = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the wind direction: ");

windD = Double.parseDouble(kybd.nextLine());

System.out.print("Enter the wind speed in knots: ");

windS = Double.parseDouble(kybd.nextLine());

E6BFlightComputer FC = new E6BFlightComputer(stationP, stationT, aircraftA, Iairspeed,

windD, desiredC, windS);

System.out.printf("Density Altitude: .2f ", FC.getDensityAltitude());

System.out.println("True air speed: " + FC.getTrueAirSpeed());

System.out.println("Wind correction angle: " + FC.getTrueAirSpeed());

System.out.println("Ground speed: " + FC.getGroundSpeed());

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote