12,947,948 members (81,832 online)
Rate this:
See more:
Hello i have a code project due tomorrow that i couldn't do because of exam studying. Aside from all my excuses, my teacher wants me to do a code that simulates an airplane control center. The expectations are to output the inserted x,y,z coordinates and keep decreasing them by one every second until the the distance is 15 and tells the pilot whether or not he/she has enough fuel to land. If not he/she must make an emergency landing. the output should be for example.

e.g:
you are now at __ x coordinate
you are now at __ y coordinate
you are now at __ z coordinate
you are going at __ speed, Total flight time is __
you are __ away from landing. (distance)

the code has to be very basic as im only in grade 10 and my teacher wants only simple code. What i've done so far only outputs the x,y,z.

(this is what i have so far)
#{Filename: <airplane control=""> }
#{Program : At 20 distance of the landing it tells the pilot if help/she
#has enough fuel or not and outputs the coordinates.}
#{Outline program. checks if you plane is at 20 distance if it isnt it
#decreases by one and keeps looping until its 20}
#{Programmer : <james cui=""> }
#{Class : Class/Section (Mr.Sze) }
#{Due Date : <january,28,> }

import random
import math
import time

iend=1
icounter=0
iconsump=50 #per hour
idestination= (0,0,0)
idistance= math.sqrt((ix)^2+(iy)^2+(iz)^2)
itime= idistance/ispeed
iremain= itime*iconsump
iwind= random.randrange (1,50)

while iend > 0:
ixdeducted = random.randint(1,2)
if ix > 0:
if ix == 1:
ix = ix - 1
else:
ix = ix - ixdeducted
else:
ix = ix + 0
print "You are now at",ix,"on the X coordinate."
iydeducted = random.randint(1,2)
if iy > 0:
if iy == 1:
iy = iy - 1
else:
iy = iy - iydeducted
else:
iy = iy + 0
print "You are now at",iy,"on the Y coordinate."
izdeducted = random.randint(1,2)
if iz > 0:
if iz ==1:
iz = iz -1
else:
iz = iz - izdeducted
else:
iz = iz + 0
print "You are now at",iz,"on the Z coordinate."
print "You were flying for a total of",itime,"hours"

if idistance<=15:
if ifuel<iremain: xmlns:iremain="#unknown">
print "you do not have enough fuel,please make an emergency landing"
iend==0
else:
print "you have enough fuel to land, please proceed"
Posted 27-Jan-13 15:04pm
jwingxx102
Updated 27-Jan-13 15:06pm
v2

Rate this:

## Solution 1

This is not a question. It looks like you want other people to do your work for you. Besides, you want to cheat against your fellows who are doing things with your hands.

However, they are not going to be the losers, but you are. You are given a change to learn something; use this chance well. It will only work for you if you do it by yourself.

Sorry, you are not doing your work for you. We are helping people; and the best help you need right now is: get to work.

—SA

Top Experts
Last 24hrsThis month
 OriginalGriff 445 Maciej Los 250 F-ES Sitecore 195 Kornfeld Eliyahu Peter 130 CPallini 125
 OriginalGriff 5,344 CHill60 3,275 Maciej Los 2,628 Jochen Arndt 1,935 ppolymorphe 1,795