Jowan3 / Jowan_2025

Apache License 2.0
0 stars 0 forks source link

Jowan Elzein: 3.6 & 3.7 Hacks and Homework #10

Open Jowan3 opened 6 days ago

Jowan3 commented 6 days ago

3.6 Hacks and Homework

Javascript Conditionals function getGrade() { // Prompt the user to enter a score let score = prompt("Enter the score (0-100):"); score = Number(score); // Convert input to a number

// Check conditions to assign grades based on the score
if (score >= 90) {
    console.log("A"); // A grade for scores 90 and above
} else if (score >= 80) {
    console.log("B"); // B grade for scores between 80 and 89
} else if (score >= 70) {
    console.log("C"); // C grade for scores between 70 and 79
} else {
    console.log("F"); // F grade for scores below 70
}

}

// Call the function to get a grade getGrade();

HW Question 1: Voting Eligibility

function checkVotingEligibility() { // Get user input for age let age = prompt("Enter your age:");

// Convert input to a number
age = Number(age);

// Determine if the user is eligible to vote
if (age >= 18) {
    console.log("You are eligible to vote.");
} else {
    console.log("You are not eligible to vote.");
}

}

// Call the function to check voting eligibility checkVotingEligibility();

HW Question 2: Food Choice Based on Health Status

def food_choice(): health_status = input("Are you healthy, unhealthy, or indifferent about food? (healthy/unhealthy/indifferent): ").strip().lower()

if health_status == "healthy":
    print("You should eat an apple!")
elif health_status == "unhealthy":
    print("You should eat chocolate!")
elif health_status == "indifferent":
    print("You don't care about what you eat. How about a coffee?")
else:
    print("Invalid input! Please enter 'healthy', 'unhealthy', or 'indifferent'.")

food_choice()