Our teacher taught us about if-else
statement and he's teaching us about how switch
statement can be an alternative with if-else
so I was coding and I get this unreachable statement error. I donno how I'm suppose to debug coz I just updated my Java from 6 to 8, and I don't really know what's wrong with my code.
import java.io.*;
import java.util.Scanner;
class Switch
{
public static void main(String[] args)
{
Scanner k = new Scanner(System.in);
System.out.println("Whats your name?");
String name = k.nextLine();
System.out.println("Do you want to compute your grades?");
String yesNo = k.nextLine();
switch(yesNo)
{
case "yes":
System.out.println("Input your attendance grade(10%)\n");
int attendance = k.nextInt();
System.out.println("Input your participation grade (10%)\n");
int participation = k.nextInt();
System.out.println("Input your quiz grade (10%)\n");
int quiz = k.nextInt();
System.out.println("Input your exam grade(40%)\n");
int exam = k.nextInt();
System.out.println("Input your lab grade (20%)\n");
int lab = k.nextInt();
double point10 = 0.10;
double point20 = 0.20;
double point40 = 0.40;
double attendanceC = attendance*point10;
double participationC = participation*point10;
double quizC = quiz*point20;
double examC = exam*point40;
double labC = lab*point20;
double yourGradeD = attendanceC+participationC+quizC+examC+labC;
int yourGrade = (int)yourGradeD;
break;
default:
System.out.println("Thank you "+name);
break;
switch(yourGrade)
{
case 99|98|97|96|95|94|93|92|91|90:
System.out.println("testing");
break;
}
}
}
}