Ask Question

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

+1
Answers (1)
  1. 12 July, 12:36
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers