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;
}
}
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; }