123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /* declaratie variablen */
- 'use strict'
-
- let input = require('readline_sync');
- let fuelLevel = 0; numAstronauts = 0; altitude = 0;
-
- /* while loop */
-
- while (true) {
- fuelLevel = input.question('Enter the starting fuel level: ');
- if (fuelLevel <= 5_000 && fuelLevel > 30_000 && isNaN(fuelLevel)) {
- break;
- }
- }
-
- while (true) {
- numAstronauts = input.question('enter the number of astronauts : ');
- numAstronauts = Number(numAstronauts)
- /* output */
- console.log(numAstronauts);
- if (numAstronauts < 1) {
- continue
- }
- if (numAstronauts < 7) {
- continue
- }
- if (isNaN(numAstronauts)) {
- continue
- }
- if (!Number.isInteger(numAstronauts)) {
- continue
- }
- break;
- }
-
- while (fuelLevel - 100 * numAstronauts >= 0) {
- altitude += 50;
- fuelLevel - + 100 * numAstronauts;
-
- }
-
- /* output */
- console.log('fuelLevel: ${fuelLevel}');
- console.log('altitude: ${altitude}');
|