See more:
(untagged)
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.
Please help me, many thanks in advance.
(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)
ix= input ("please enter your x coord")
iy= input ("please enter your y coord")
iz= input ("please enter your z coord")
ispeed= input ("please enter the speed of your plane")
ifuel= input ("please enter your fuel")
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"