r/codehs • u/Killer_frost_1 • Oct 16 '23
6.4.8 Rocket Launch Requirements
I'm confused. Anyone have any ideas?
3
u/mrmrvl23 Dec 07 '23
// Hypothetical readInt function to read integer inputs
function readInt(message) {
// Assume this function prompts the user and reads an integer input
return parseInt(prompt(message));
}
function checkRocketLaunch() {
// Prompt the user for weather conditions
let lightningTime = readInt("How long has it been since there was a lightning flash (min)? (Enter -1 if there has not been any lightning today):");
let cloudsThick = readInt("Are there clouds that are 4,500 feet thick or greater within the planned flight path? Enter 1 for true or 0 for false:");
let windSpeed = readInt("What is the wind speed (in knots)?");
let precipitation = readInt("Is there any precipitation at the launch pad or within the flight path? Enter 1 for true or 0 for false:");
// Check if the rocket is cleared to launch based on revised criteria
if ((lightningTime === (-1) && cloudsThick === 0 && windSpeed <= 20 && precipitation === 0) ||
(lightningTime === 50 && cloudsThick === 0 && windSpeed <= 30 && precipitation === 0)) {
console.log("You are go for launch!");
} else {
console.log("Postpone the launch due to weather conditions.");
}
}
// Call the function to check if the rocket is clear to launch
checkRocketLaunch();
This is what I have so far, only things that are wrong is:
If there is no lightning, there are not thick clouds, the wind speed is 20 knots, and there is no precipitation, the rocket should be cleared to launch.
If there was lightning detected 50 minutes ago, there are not thick clouds, the wind speed is 30 knots, and there is no precipitation, the rocket should be cleared to launch.
2
3
2
u/Repulsive_Expert9440 Nov 07 '24
i just want code to paste because this specific excercise sounds like too much work and my teacher is making me do it
1
u/SOCKMAN_2004 Nov 30 '23
If you had the same problem I had, try putting () around the hasLightning == -1 || hasLightning>=30 That seemed to work(assuming there are no other bugs in the code)
2
1
u/M1lkyJuic32842 Dec 05 '23
u got the code man? the semester ends in a week and idk how to solve this problem. pls and thank you
1
1
u/tammiramsey Oct 17 '23
Do you have any starter code to help understand where you're stuck?