View Single Post
Old Apr 29th, 2005, 9:37 PM   #2
Haz
Programmer
 
Haz's Avatar
 
Join Date: Feb 2005
Location: England
Posts: 37
Rep Power: 0 Haz is on a distinguished road
Send a message via ICQ to Haz Send a message via AIM to Haz Send a message via MSN to Haz Send a message via Yahoo to Haz
Well I've completed it and I cmplied it, but there are some errors that I'm not exactly sure about, and everytime I try to correct them, it gets worse. Here's the code:

/* Aviation program for Pilots

   Created by Harry Wheildon  */

using System;

class Avi {
  public static void Main() {

    char choice;
    char std;
    double speed;
    double distance;
    double time;
    int alt;
    double tempx;
    double x, y, z, a;
    int ac1, ac2;
    double vis;
    double dt, dg, te, dtg, ca;	
    int degreesAdd (int n1, int n2)
    {
    return (n1 + n2) % 360;
    }
     for(;;) {
     	 do {              

	Console.WriteLine("Choose one from the list:\n");	
	Console.WriteLine("1.  Speed; Distance; Time");
	Console.WriteLine("2.  ISA Deviation");
    Console.WriteLine("3.  Time to Impact");
	Console.WriteLine("4.  Track Error; Closing Angle\n");
	Console.Write("Choose one (press Q to quit): ");
	do {
	  choice = (char) Console.Read();
        } while(choice == '\n' | choice == '\r');
      } while( choice < '1' | choice > '4' & choice != 'q' );

      if(choice == 'q') break;

      Console.WriteLine("\n");

      switch(choice) {
	case '1':
	  Console.WriteLine("Here you can calculate the Speed, Distance or Time\n")
	  Console.WriteLine("Choose which one you want to calculate:")
	  Console.WriteLine("1.  Speed")
 	  Console.WriteLine("2.  Distance")
	  Console.WriteLine("3.  Time\n")
	  Console.Write("Choose one (press B to go back): ");
	  do {
	   std = (char) Console.Read();
	  } while(choice == '\n' | choice == '\r');
      } while( choice < '1' | choice > '3' & choice != 'b');

	if(choice == 'b') break;

	Console.WriteLine("\n");
	
	switch(std) {
  	  case '1':
	    Console.Write("Distance: ");
	    distance = (double) Console.Read();
	    Console.Write("Time: ");
	    time = (double) Console.Read();

	    speed = distance / time;

	    Console.WriteLine("Your Distance was: " + distance);
	    Console.WriteLine("Your Time was: " + time);

            Console.WriteLine("Thus your Speed is " + speed);

	    Console.WriteLine("NOTE: Make sure the units are compatible with each other");
	    break;

	  case '2':
	    Console.Write("Speed: ");
	    speed = (double) Console.Read();
	    Console.Write("Time: ");
	    time = (double) Console.Read();

	    distance = speed * time;

	    Console.WriteLine("Your Speed was: " + speed);
	    Console.WriteLine("Your Time was: " + time);
	    
	    Console.WriteLine("Thus your Distance is: " + distance);
	    break;

	  case '3':
	    Console.Write("Speed: ");
	    speed = (double) Console.Read();
	    Console.Write("Distance: ");
	    distance = (double) Console.Read();

	    time = distance / speed;

	    Console.WriteLine("Your Speed was: " + speed);
	    Console.WriteLine("Your Distance was: " + distance);
	    
	    Console.WriteLine("Thus your Time is: " + time);	   
	    break;
	}
	  case '2':
	    Console.WriteLine("Here you can calculate the ISA deviation\n");
	    Console.Write("Altitude: ");
	    alt = (int) Console.read();
	    Console.Write("Temp. at Alt.: ");
	    tempx = (double) Console.Read()

	    x = alt - 1000;
	    y = 2 * x;
	    z = 15 - x;

	    Console.WriteLine("This is the ISA temp. at that level: " + z);
	    
	    a = tempx - z;

	    Console.WriteLine("This is the ISA Deviation: " + a);
	    break;
	  
          case '3':
	    Console.WriteLine("Here you can calculate the Time to Impact of 2 aircraft\n");
	    Console.Write("Speed of Aircraft 1: ");
	    ac1 = (int) Console.Read();
	    Console.Write("Speed of Aircraft 2: ");
	    ac2 = (int) Console.Read();
	    
	    speed = ac1 + ac2;

	    Console.WriteLine("Your closing speed is: " + speed);

	    Console.WriteLine("Now the program will convert the in-flight visibility from Kilometres to Nautical Miles.");
	    
	    Console.Write("In-flight vis. (km): ");
	    vis = (double) Console.Read();
 	    
            x = ( vis * 1000 * 3.128 ) / (6076);
            Console.WriteLine("Your in-flight vis. is: " + x "nm");

	    Console.WriteLine("Now the program will calculate the time to impact in hours");
	    y = x / speed;
	    Console.WriteLine("The Time to Impact is: " + y "hours\nNow it will convert it into seconds");
	    z = y * 3600;
	    Console.WriteLine("\nYour Time to Impact is: " + z "seconds");
	    break;
	
	  case '4':
	    Console.WriteLine("Here you can calculate the Track Error, Closing Angle, and the angle at which\n to travel to get to the destiniation"); 
	    Console.Write("Distance Off Track: ");
	    dt = (double) Console.Read();
	    Console.Write("Distance Gone ");
	    dg = (double) Console.Read();
	    
	    x = (dt) / (dg);
	    y = x * 60;
	    
	    Console.WriteLine("The Track Error is: " + y "degrees");
	    
	    Console.WriteLine("Now the prgram will calculate the Closing Angle");
	    Console.Write("Distance to go: ");
	    dtg = (double) Console.Read();
	    
	    z = (dt) / (dtg);
	    
	    a = z * 60;
	    
	    Console.WriteLine("The Closing Angle is: " + a "degrees");
	    
	    Console.WriteLine("Now the program will figure out the directiong to fly to get to the destination");
	    
	    z = addDegrees (a, y);
	    
	    Console.WriteLine("The angle at which to travel to get to the destination is" + z "degrees");
	    break;
      }
	    
    }
    Console.WriteLine();
	}
}

And here's the output:

AviProgram.cs(20,32): error CS1513: } expected
AviProgram.cs(25,6): error CS1519: Invalid token 'for' in class, struct, or interface member declaration
AviProgram.cs(28,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(29,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(30,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(31,22): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(32,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(33,15): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(35,11): error CS1519: Invalid token '=' in class, struct, or interface member declaration
AviProgram.cs(35,18): error CS1519: Invalid token ')' in class, struct, or interface member declaration
AviProgram.cs(35,32): error CS1519: Invalid token '(' in class, struct, or interface member declaration
AviProgram.cs(36,11): error CS0116: A namespace does not directly contain members such as fields or methods
AviProgram.cs(37,7): error CS1022: Type or namespace definition, or end-of-file expected

---------------------- Done ----------------------

Build: 0 succeeded, 0 failed

Will someone be able to tell me where I went wrong and help me sort it out? Thankyou

Haz
Haz is offline   Reply With Quote