1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kvasek [131]
3 years ago
13

Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grade

s in each letter grade defined as follows:
90-100 is an A, 80-89 is a B, 70-79 is a C, 60-69 is a D, 0-59 is an F. Use a negative score as a sentinel to indicate the end of the input. (The negative value is used just to end the loop, do not use it in the calculations). Then output the highest and lowest score, and the average score.

For example if the input is: 72 98 87 50 70 86 85 78 73 72 72 66 63 85 -1

the output would be:

Total number of grades = 14

Number of As =1

Number of Bs = 4

Number of Cs = 6

Number of Ds = 2

Number of Fs = 1

The highest score is 98

The lowest score is 50

The average is 75.5
Computers and Technology
1 answer:
Tju [1.3M]3 years ago
3 0

Answer:

import java.util.Scanner;

public class Program

{

  public static void main(String [] Args)

  {

      int totalAGrades = 0, totalBGrades = 0, totalCGrades = 0, totalDGrades = 0, totalFGrades = 0, counter=0,maximum = 0, minimum = 9999, num, total = 0,smallest = 0,largest = 0;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter exam percentage: ");

       System.out.println("Enter a negative examScore: ");

       int examScore = in.nextInt();

       while(examScore > 0)

       {

         counter++;

         if(examScore < 0){          

             break;}  

         else if(examScore > maximum){      

              maximum = examScore;}

         else if(examScore < minimum)   {  

              minimum = examScore;}

         

          total = total + examScore;  

     

          if(examScore <= 50 && examScore>0)

              smallest = examScore;

              if(examScore > 90 && examScore <=100)

              largest = examScore;

         

      if(examScore>=90 && examScore<=100)

          totalAGrades++;

      else if(examScore>=80 && examScore<=89)

          totalBGrades++;

      else if(examScore>=70 && examScore<=79)

          totalCGrades++;

      else if(examScore>=60 && examScore<=69)

          totalDGrades++;

      else if(examScore>=0 && examScore<=59)

          totalFGrades++;

      examScore = in.nextInt();

     

   }

      System.out.println("Total number of scores is = " + counter );

      System.out.println("Total Number of each Letter grade : " + counter);

      System.out.println("Percentage of total for each letter grade : ");

          System.out.println("Total number of A grades = "+ totalAGrades);

          System.out.println("Total number of B grades = "+ totalBGrades);

          System.out.println("Total number of C grades = "+ totalCGrades);

          System.out.println("Total number of D grades = "+ totalDGrades);

          System.out.println("Total number of F grades = "+ totalFGrades);

     

      System.out.println("Lowest exam Score is :"+smallest);

      System.out.println("Highest exam Score is :"+largest);

      System.out.println("Average exam Score = "+ (total / counter));

  }

}  

Explanation:

  • Get the exam information from user as input and run a while loop until examScore is greater than zero.
  • Use conditional statement to check the scores of students and increment the relevant grade accordingly.
  • Finally display all the information including grades and scores.
You might be interested in
Finish this for brainliest and 30 points
n200080 [17]
What do you mean what are we supposed to finish

6 0
2 years ago
The following is a training dataset that has ten one dimensional objects.
grandymaker [24]
Yes no no false . . . .
6 0
2 years ago
How many bits are required to encode an image that is 25 pixels wide and 50 pixels tall, if you encode each pixel with 12 bits o
AURORKA [14]

Just multiply all numbers to get the total number of bits:

25*50*12 = 15000 bits.

3 0
3 years ago
To rearrange the data on your hard disk so your computer can run more efficiently, you use ____.
Ratling [72]
A disk optimization program, but they're probably looking for defragmenting program.
5 0
3 years ago
A method countDigits(int num) of class Digits returns the remainder when the input argument num(num &gt; 0) is divided by the nu
sertanlavr [38]

Answer:

#include <iostream>

using namespace std;

class Digits

{

   public:

   int num;

   int read()       //method to read num from user

   {

       cout<<"Enter number(>0)\n";

       cin>>num;

       return num;

   }

   int digit_count(int num)  //method to count number of digits of num

   {

       int count=0;

       while(num>0)    //loop till num>0

       {

           num/=10;

           count++;   //counter which counts number of digits

       }

       return count;

   }

   int countDigits(int num)   //method to return remainder

   {

       int c=digit_count(num); //calls method inside method

       return num%c;  

   }

};

int main()

{

   Digits d;    //object of class Digits is created

   int number=d.read();   //num is read from user

   cout<<"\nRemainder is : "<<d.countDigits(number);  //used to find remainder

   return 0;

}

Output :

Enter number(>0)

343

Remainder is : 1

Explanation:

As program is missing to find errors , a logically write program is written to find the remainder when a number is divided by its number of digits. A class  Digits is constructed which has public variable num and methods read(), digit_count(), countDigits().

  • read() - This method reads value of num from the user and return num.
  • digit_count() - This method takes a integer as parameter and counts the number of digits of a number passed as argument. while loop is used to increement the counter until num<0. This returns the value of count.
  • countDigits() - This method takes a integer as a parameter and returns remainder when the argument is divided by number of  digits of argument. Number of digits is calculated by using method digit_count().

At last in main method , object of Digits class is created and its methods are used to find the output.

7 0
3 years ago
Other questions:
  • If you have a 3D printer please show me a vid of you making something because I'm interested in getting one. Ty! Also can someon
    12·1 answer
  • Savings accounts typically offer more interest than what
    10·1 answer
  • How do you adjust the shear of a shape?
    10·2 answers
  • Where should you click to edit an existing formula?
    12·2 answers
  • What items do you keep in a data base
    5·1 answer
  • Gini is a manager at a website design firm. She has a timeline prepared for the product to be delivered to the client. She needs
    6·2 answers
  • What is SoC? how is it different from CPU?
    14·1 answer
  • Please help please I will count your answer brainiest if you help!
    8·1 answer
  • 2. What is the name for an action performed by the VR Robot?
    7·2 answers
  • Which device is used to direct the flow of data on a computer network?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!