Doing a small quiz program. At the end trying to do a percentage but I get 0. Dont know why. The code is below:
import java.util.Scanner;
public class Quiz
{
public static void main(String[] args)
{
Scanner ms = new Scanner(System.in);
System.out.println("HIP-HIP MUSIC QUIZ");
System.out.print("\n1) What is the real name of famous hiphop Rapper 50 Cent ? \nA - Wayne Marshal \nB - Curtis Jackson \nC - Marion Jones \nD - Jamie Foxx\n");
System.out.print("\nYour answer: ");
String quest1 = ms.nextLine();
int marks = 0;
final int questions = 4;
int percent = 0;
switch(quest1)
{ case "A":
System.out.println("Wrong !!! Correct Answer was: B - Curtis Jackson");
break;
case "B":
System.out.println("Correct !!!");
marks++;
break;
case "C":
System.out.println("Wrong !!! Correct Answer was: B - Curtis Jackson");
break;
case "D":
System.out.println("Wrong !!! Correct Answer was: B - Curtis Jackson");
break;
default:
System.out.println("Sorry... Invalid Input");
}
System.out.print("\n2) The nickname Weezy is know to which artist ? \nA - Wayne Little \nB - Lil Wee \nC - Wesley Tip \nD - Lil Wayne\n");
System.out.print("\nYour answer: ");
String quest2 = ms.nextLine();
switch(quest2)
{ case "A":
System.out.println("Wrong !!! Correct Answer was: D - Lil Wayne");
break;
case "B":
System.out.println("Wrong !!! Correct Answer was: D - Lil Wayne");
break;
case "C":
System.out.println("Wrong !!! Correct Answer was: D - Lil Wayne");
break;
case "D":
System.out.println("Correct !!!");
marks++;
break;
default:
System.out.println("Sorry... Invalid Input");
}
System.out.print("\n3) Which rapper is known as 'The King' ? \nA - T.I \nB - Taio Cruz \nC - King Shady \nD - Eminem\n");
System.out.print("\nYour answer: ");
String quest3 = ms.nextLine();
switch(quest3)
{ case "A":
System.out.println("Correct !!!");
marks++;
break;
case "B":
System.out.println("Wrong !!! Correct Answer was: A - T.I");
break;
case "C":
System.out.println("Wrong !!! Correct Answer was: A - T.I");
break;
case "D":
System.out.println("Wrong !!! Correct Answer was: A - T.I");
break;
default:
System.out.println("Sorry... Invalid Input");
}
System.out.print("\n4) Chris Brown is a ________________ & _________________ ? \nA - Producer & Rapper \nB - Backup Singer & Vocalist \nC - Singer & Dancer \nD - Guitarist & Violin Player\n");
System.out.print("\nYour answer: ");
String quest4 = ms.nextLine();
switch(quest4)
{ case "A":
System.out.println("Wrong !!! Correct Answer was: C - Singer & Dancer");
break;
case "B":
System.out.println("Wrong !!! Correct Answer was: C - Singer & Dancer");
break;
case "C":
System.out.println("Correct !!!");
marks++;
break;
case "D":
System.out.println("Wrong !!! Correct Answer was: C - Singer & Dancer");
break;
default:
System.out.println("Sorry... Invalid Input");
}
percent = ((marks / questions) * 100);
System.out.println("You got " + percent+"%");
}
}