Ask Question
19 October, 04:30

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;

}

}

+2
Answers (1)
  1. 19 October, 05:18
    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 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