goal: learn to write multi - way if statements.\nassignment: given a variable grade, already declared and…

goal: learn to write multi - way if statements.\nassignment: given a variable grade, already declared and initialized: print on screen the following message:\n. “your grade is: a” if the grade is 90 or greater\n. “your grade is: b” if the grade is 80 or greater, but under 90\n. “your grade is: c” if the grade is 70 or greater, but under 80\n. “your grade is: d” if the grade is 60 or greater, but under 70\n. “your grade is: f” if the grade is lower than 60

goal: learn to write multi - way if statements.\nassignment: given a variable grade, already declared and initialized: print on screen the following message:\n. “your grade is: a” if the grade is 90 or greater\n. “your grade is: b” if the grade is 80 or greater, but under 90\n. “your grade is: c” if the grade is 70 or greater, but under 80\n. “your grade is: d” if the grade is 60 or greater, but under 70\n. “your grade is: f” if the grade is lower than 60

Answer

Explanation:

Step1: Use if - elif - else structure

grade = 85 # Assume an example value for grade
if grade >= 90:
    print("Your grade is: A")
elif grade >= 80:
    print("Your grade is: B")
elif grade >= 70:
    print("Your grade is: C")
elif grade >= 60:
    print("Your grade is: D")
else:
    print("Your grade is: F")

Answer:

The above Python code will print the appropriate grade message based on the value of the grade variable. If you want to implement it in another programming language, the logic of the multi - way if statements will be similar but the syntax may vary. For example, in Java:

int grade = 85; // Assume an example value for grade
if (grade >= 90) {
    System.out.println("Your grade is: A");
} else if (grade >= 80) {
    System.out.println("Your grade is: B");
} else if (grade >= 70) {
    System.out.println("Your grade is: C");
} else if (grade >= 60) {
    System.out.println("Your grade is: D");
} else {
    System.out.println("Your grade is: F");
}