Ask Question
12 April, 18:28

Assume that credits is an int variable whose value is 0 or positive. Write an expression whose value is "freshman" or "sophomore" or "junior" or "senior" based on the value of credits. In particular: if the value of credits is less than 30 the expression's value is "freshman"; 30-59 would be a "sophomore", 60-89 would be "junior" and 90 or more would be a "senior".

+5
Answers (1)
  1. 12 April, 21:59
    0
    C+ + Code

    #include / /for input and output

    using namespace std;

    int main ()

    {

    int credit = 10;

    if (credit<30) {

    cout<<"frehsman";

    }

    else if (credit>=30 && credit<60) {

    cout<<"sophomore";

    } else if (credit>=60 && credit<90) {

    cout<<"junior";

    } else if (credit>=90) {

    cout<<"senior";

    }

    return 0;

    }

    Code Explanation

    First declare credits variable and assign the desired value to it. then check credits value by using else if in which by applying its condition, print the appropriate expression.

    Output

    Case 29:

    freshman

    Case 59:

    sophomore
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume that credits is an int variable whose value is 0 or positive. Write an expression whose value is "freshman" or "sophomore" or ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers