Ask Question
19 March, 21:53

Can you format the question in if-statements or other forms using this code segment?

public void setQuiz (int quiz, int grade)

{

switch (quiz)

{

case 1: / / if quiz = = 1

grade1 = grade; / / where was grade1 declared?

break; / / otherwise execution will continue through the next case block

case 2: / / if quiz = = 2

grade2 = grade;

break;

}

}

+4
Answers (1)
  1. 19 March, 23:11
    0
    I don't know where grade1 or grade2 comes from, as we are only seeing one function, so I assume that those two variables are other variables in the class.

    public void setQuiz (int quiz, int grade)

    {

    if (quiz = = 1)

    grade1 = grade;

    else if (quiz = = 2)

    grade2 = grade;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Can you format the question in if-statements or other forms using this code segment? public void setQuiz (int quiz, int grade) { switch ...” 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