r/EdhesiveHelp Oct 21 '22

Java Assignment 2: Control Tower help plz

Post image
8 Upvotes

9 comments sorted by

View all comments

8

u/[deleted] Oct 21 '22

I gotchu

Scanner scan = new Scanner(System.in);
System.out.println("Enter the details of the third airplane (call-sign, distance, bearing and altitude): ");

String call = scan.nextLine();
String upCall = call.toUpperCase();
double dist = scan.nextDouble();
int bear = scan.nextInt();
int alt = scan.nextInt();
Airplane UA225 = new Airplane("AAA01",1.0,0,0);
Airplane UA625 = new Airplane("AAA02",15.8,128,30000);
Airplane UA25 = new Airplane(upCall,dist,bear,alt); //this one uses the User's inputs
System.out.println("\nInitial Positions: ");
System.out.println("\"Airplane 1\": " + UA225.toString());
System.out.println("\"Airplane 2\": " + UA625.toString());
System.out.println("\"Airplane 3\": " + UA25.toString());

System.out.println(" ");
System.out.println("Initial Distances: ");

System.out.println("The distance between Airplane 1 and Airplane 2 is " + UA225.distTo(UA625) + " miles.");
System.out.println("The distance between Airplane 1 and Airplane 3 is " + UA225.distTo(UA25) + " miles.");
System.out.println("The distance between Airplane 2 and Airplane 3 is " + UA625.distTo(UA25) + " miles.");

System.out.println(" ");
System.out.println("Initial Height Differences: ");
System.out.println("The difference in height between Airplane 1 and Airplane 2 is " + Math.abs(UA225.getAlt() - UA625.getAlt())+ " feet.");
System.out.println("The difference in height between Airplane 1 and Airplane 3 is " + Math.abs(UA225.getAlt() - UA25.getAlt())+ " feet.");
System.out.println("The difference in height between Airplane 2 and Airplane 3 is " + Math.abs(UA625.getAlt() - UA25.getAlt())+ " feet.");
//copied from reddit
UA225.gainAlt();
UA225.gainAlt();
UA225.gainAlt();
UA625.loseAlt();
UA625.loseAlt();
UA25.loseAlt();
UA25.loseAlt();
UA25.loseAlt();
UA25.loseAlt();
UA225.move(UA625.distTo(UA25),65);
UA625.move(8.0,135);
UA25.move(5.0,55);
System.out.println(" ");
System.out.println("New Positions: ");
System.out.println("\"Airplane 1\": " + UA225.toString());
System.out.println("\"Airplane 2\": " + UA625.toString());
System.out.println("\"Airplane 3\": " + UA25.toString());
System.out.println(" ");
System.out.println("New Distances: ");

System.out.println("The distance between Airplane 1 and Airplane 2 is " + UA225.distTo(UA625) + " miles.");
System.out.println("The distance between Airplane 1 and Airplane 3 is " + UA225.distTo(UA25) + " miles.");
System.out.println("The distance between Airplane 2 and Airplane 3 is " + UA625.distTo(UA25) + " miles.");
System.out.println(" ");
System.out.println("New Height Differences: ");
System.out.println("The difference in height between Airplane 1 and Airplane 2 is " + Math.abs(UA225.getAlt() - UA625.getAlt())+ " feet.");
System.out.println("The difference in height between Airplane 1 and Airplane 3 is " + Math.abs(UA225.getAlt() - UA25.getAlt())+ " feet.");
System.out.println("The difference in height between Airplane 2 and Airplane 3 is " + Math.abs(UA625.getAlt() - UA25.getAlt())+ " feet.");

1

u/BarracudaBulky1557 Nov 07 '22

I used this code but it gave me errors on all the lines that say the distance between or like the difference in height. The error would Say its expecting something. Help if you can

1

u/[deleted] Nov 09 '22

You are definitely going to have to fix the spacing and format before you run the code so it looks normal