0

PLEASE HELP CODE NOT WORKING PROPERLY

Hi community I made a program for homework that is supposed to give my test score but it keeps returning my answer as 0% always here is my code; import javax.swing.JOptionPane; public class TestScore { public static void main(String[]args) { String inputQT; String inputQC; int QuestionsTotal; int QuestionsCorrect; double Percent; inputQT = JOptionPane.showInputDialog("How many questions were on the test:"); QuestionsTotal = Integer.parseInt(inputQT); inputQC = JOptionPane.showInputDialog("How many questions did you answer correct:"); QuestionsCorrect = Integer.parseInt(inputQC); Percent = QuestionsCorrect / QuestionsTotal; JOptionPane.showMessageDialog(null, "You got " + QuestionsCorrect + " out of " + QuestionsTotal + "." + " Your percentage is " + Percent + "%"); } }

7th Oct 2016, 5:12 AM
SequenceDesigns
1 Odpowiedź
0
Run Debug and see if your variables are taking the numbers correctly.
13th Oct 2016, 9:19 PM
Santiago Rodriguez
Santiago Rodriguez - avatar