Ask Question

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;

}

}

+3
Answers (1)
  1. 26 April, 19:35
    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?
Find 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 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