View Single Post
Old May 1st, 2005, 8:44 PM   #6
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
Yep, kind of worked, just ONE more error to sort out :-(.

AviProgram.cs(183,1): error CS1022: Type or namespace definition, or end-of-file expected

/* Aviation program for Pilots

   Created by Harry Wheildon  */

using System;

class Avi {
	int degreesAdd (int n1, int n2)
	{
		return (n1 + n2) % 360;
	}
	public static int 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;
		
		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':
					do {
						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: ");
						do {
							std = (char) Console.Read();
						} while(choice == '\n' | choice == '\r');
					} while( choice < '1' | choice > '3');
					
					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 program 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 direction 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();
	}
  }
}


That's the code completed so far.

Thanks for all the help you guys have given me
Haz is offline   Reply With Quote