Its an intro java homework question so please avoide using a
Solution
Hi, Please find my code. Please let me know in case of any issue.
import java.util.Scanner;
public class TotalScore {
public static void main(String[] args) {
// scanner object to take user input
Scanner sc = new Scanner(System.in);
System.out.println(\"Enter strudent scores (enter negative value to stop): \");
double total = 0; // initializing totl value with zero
double score;
score = sc.nextDouble(); // taking first user input
while(score > 0){
total = total + score ; // adding current score in total
score = sc.nextDouble();
}
System.out.println(\"Total score: \"+total);
}
}
/*
Sampel Output:
Enter strudent scores (enter negative value to stop):
45.4
32
67
89.0
78.5
-3
Total score: 311.9
*/


