Its an intro java homework question so please avoide using a


Its an intro java homework question so please avoide using advanced concepts while coding.
Thank you
Write a program with a loop that lets the user enter a series of exam scores taken for a student. Each score entered should be added to a total. Give the user instructions to enter a negative value to indicate the end of the series. After all the numbers have been entered, the program should display \"Total scores:\" followed by the total.

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

*/

 Its an intro java homework question so please avoide using advanced concepts while coding. Thank you Write a program with a loop that lets the user enter a ser
 Its an intro java homework question so please avoide using advanced concepts while coding. Thank you Write a program with a loop that lets the user enter a ser

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site