Ask Question
27 June, 10:14

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".

+2
Answers (1)
  1. 27 June, 13:09
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers