|
|
@@ -1,22 +1,39 @@ |
|
|
|
let input = require('readline-sync'); |
|
|
|
let fuelLevel = input.question("What is the starting fuel?\n"); |
|
|
|
let nAstro = input.question('How many astronauts are present?\n'); |
|
|
|
let i = 0; |
|
|
|
let fuelLevel = 0; |
|
|
|
let nAstro = 0; |
|
|
|
let altitude = 0; |
|
|
|
|
|
|
|
while (fuelLevel > 0) { |
|
|
|
if (fuelLevel < 5000 || fuelLevel > 30_000) { |
|
|
|
while (true) { |
|
|
|
fuelLevel = input.question('What is the starting fuel level?\n'); |
|
|
|
if (fuelLevel > 5000 && fuelLevel < 30_000 && !isNaN(fuelLevel)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (nAstro <= 1 || nAstro >= 7) { |
|
|
|
} |
|
|
|
|
|
|
|
while (true) { |
|
|
|
nAstro = input.question('How many astronauts are present?\n'); |
|
|
|
if (nAstro > 0 && |
|
|
|
nAstro <= 7 && |
|
|
|
!isNaN(nAstro) && |
|
|
|
Number.isInteger(Number(nAstro))) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
while (fuelLevel - (100 * nAstro) >= 0) { |
|
|
|
fuelLevel -= (100 * nAstro); |
|
|
|
i += 50; |
|
|
|
if (fuelLevel <= 100 * nAstro) { |
|
|
|
break; |
|
|
|
} |
|
|
|
altitude += 50; |
|
|
|
} |
|
|
|
console.log(`The shuttle gained an altitude of ${i} km.`); |
|
|
|
|
|
|
|
console.log(`The shuttle reached an altitude of ${altitude} km.`); |
|
|
|
if (altitude >= 2000) { |
|
|
|
console.log('Orbit reached!'); |
|
|
|
} else { |
|
|
|
console.log('orbit not reached'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|