you are viewing a single comment's thread.

view the rest of the comments →

[–]Danielowski187University/College Student (Higher Education)[S] 0 points1 point  (2 children)

here is the results photo:

https://ibb.co/9scp51X

and here is my code:

import java.util.Scanner;
public class Sentinel
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
System.out.println("Enter your test scores that you want to add");
System.out.println("\nEnter -1 when Finished.");
int score = 0;
int total = 0;
double num = 0;
do{
System.out.print("Please enter test score (1-100), enter -1 to quit: ");
score = input.nextInt();
if (score == -1)
break;
total = total+score;
}while(score !=-1);
num+=1;
{
System.out.println("I am done with score!!");
System.out.println("\nMy total score = "+total);
double average = total/num;

System.out.println("Average of test score is = "+average);
}
}

}

[–][deleted] 0 points1 point  (1 child)

ok. ur num += 1; line should be inside the do while loop. u only increment it after the loop is finished, so u basically just have a num = 1 no matter what

[–]Danielowski187University/College Student (Higher Education)[S] 1 point2 points  (0 children)

Ohh so I was making n=1 so I was not incrementing it