hey im trying to write a program that has a loop in it and takes the percentage of the total number of scores and the scores that passed which are above 70
here's my code when i go to run it and input the scores and it comes up with a question mark as an answer
Get back to me ASAP<import java.util.Scanner; import java.text.NumberFormat; public class DANPercentPassage { public static void main(String[] args) { int score, pass, fail, total; double percent; percent = 0; pass = 0; fail = 0; total = pass + fail; Scanner sc = new Scanner(System.in); NumberFormat per = NumberFormat.getPercentInstance(); per.setMinimumFractionDigits(2); per.setMaximumFractionDigits(0); do{ System.out.print("Enter the score: "); score = sc.nextInt(); if(score>=70) pass = pass + 1; else if(score>0&&score<70) fail = fail + 1; }while(score!=-1); percent = (double) pass/total; if(score == -1) System.out.print("The percent of the scores is "+ per.format(percent)); } } And heres my console window when i run it Enter the score: 80 Enter the score: 80 Enter the score: 35 Enter the score: 35 Enter the score: -1 The percent of the scores is ?%>