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
postnew [5]
4 years ago
14

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

ades and the number of grades in each letter-grade category as follows: 90 to 100 is a A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and 0 to 59 is an F. Use a negative score as a sentinel value to indicate the end of the input. (The negative value is used only to end the loop, so do not use it in the calculations.) For example, if the input is 98 87 86 85 85 78 73 72 72 72 70 66 63 50 -1 the output would be Total number of grades = 14 Number of A's = 1 Number of B's = 4 Number of C's = 6 Number of D's = 2 Number of F's = 1

Computers and Technology
2 answers:
d1i1m1o1n [39]4 years ago
6 0

Answer:

# user is prompt to enter a grade

grade = int(input("Enter your grade: "))

# empty list to hold user grades is declared

grade_list = []

# counter for A grade is initialised to 0

numberOfA = 0

# counter for B grade is initialised to 0

numberOfB = 0

# counter for C grade is initialised to 0

numberOfC = 0

# counter for D grade is initialised to 0

numberOfD = 0

# counter for F grade is initialised to 0

numberOfF = 0

# while loop that continue to receive

# user input as long as it is not -1

# it append each grade into the grade list

while (grade != -1):

grade_list.append(grade)

grade = int(input("Enter your grade: "))

# for loop that goes through

# the grade list and increment

# the respective grade based on

# the interval it fall

for each_grade in grade_list:

if(each_grade >= 90 and each_grade <= 100):

numberOfA += 1

elif(each_grade >= 80 and each_grade < 90):

numberOfB += 1

elif(each_grade >= 70 and each_grade < 80):

numberOfC += 1

elif(each_grade >= 60 and each_grade < 70):

numberOfD += 1

elif(each_grade >= 0 and each_grade < 60):

numberOfF += 1

# total grade is displayed to the user

print("Total number of grades = ", len(grade_list))

# number of A's is displayed to user

print("Number of A's = ", numberOfA)

# number of B's is displayed to user

print("Number of B's = ", numberOfB)

# number of C's is displayed to user

print("Number of C's = ", numberOfC)

# number of D's is displayed to user

print("Number of D's = ", numberOfD)

# number of F's is displayed to user

print("Number of F's = ", numberOfF)

Explanation:

The program is written in Python and is commented.

It asked for user input. Then it continues to receive input as long as it is not -1. It append each input to a list.

It then loop through the list and increment the correct counter for each grade.

It then display the total number of grade inputted and the number of various grade.

Maslowich4 years ago
5 0

Answer:

I am writing a C++ program.

#include <iostream> //to use input output functions

using namespace std; //to identify objects such as cout, cin

int main(){//start of main() function body

/*integer type variables A B C D and F are used to store the number of grades in each category example 90 to 100 is a A so its stored in A variable*/

               int A = 0;

 int B = 0;

 int C = 0;

 int D = 0;

 int F = 0;

 int total_grades=0; //counts and stores the total number of grades

//prompts user to enter exam scores

cout<<"Enter exam scores as integer percentages from 0 to 100:\n";

  int exam_score; // stores exam scores entered by user

  cin>>exam_score; // reads exam scores input by user

/* while loop continues to count the total number of grades and grades in each letter grade category until the user enters a negative value to end loop */

 while(exam_score>0){ //iterates till value of score is greater than 0

//increments the value of total_grades by 1 every time user enters the grade

                              total_grades++;

/*if condition checks if the value of exam_score is in the specified range of each grade category and increments that grade variable accordingly*/

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

    A++;

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

    B++;

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

    C++;

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

    D++;

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

    F++;

   cin>>exam_score;   }

/*when the loop ends the total number of grades and number of grades in each letter grade category is displayed*/

 cout<<"Total number of grades :"<<total_grades<<endl;

 cout<<"Number of A's: "<<A<<endl;

 cout<<"Number of B's: "<<B<<endl;

 cout<<"Number of C's: "<<C<<endl;

 cout<<"Number of D's: "<<D<<endl;

 cout<<"Number of F's: "<<F<<endl;

}

Explanation:

The program first prompts the user to enter the exam scores. The while loop begins which keeps counting the number of grades and stores it in total_grades variable. Then the if condition checks for each letter grade category and counts the grades in each letter grade accordingly. For example if the exam score entered by user is between 90 to 100 then this means that the letter grade category is A , so the value of A is incremented by 1. The loop continues to execute until the user enters a negative value. For example if the user enters -1, then the loop breaks. At the end the total number of grades and the number of grades in each letter grade category which are computed in the while loop are displayed as output.

You might be interested in
Given the IPv4 address in CIDR notation 215.200.110.50/25, identify the subnet ID that this address belongs to.
stich3 [128]
215.200.110.00, 215.100.110.64, 215.200.110.128,215.100.110.192
7 0
2 years ago
4.14 LAB: Countdown until matching digits In C++ Write a program that takes in an integer in the range 20-98 as input. The outpu
Fantom [35]

Answer:

Here is the C++ program:

#include <iostream>  // to use input output functions

using namespace std;   // to identify objects like cin cout

int main() { //start of main function

   int number;  //an integer value

   cout<<"Enter an integer: ";  //prompts user to enter a number

   cin >> number;  // reads integer value from user

   if (number > 98 || number < 20) {  //if number is not between 20 and 98

  cout<<"Input must be 20-98";   }  //display this message if number is not between 20 and 98

 else {  // if number is in range 20-98

   while(number%11){  // loop keeps taking mod of input number with 11 until matching digits found

       cout<<number<<" ";  //displays the numbers

       number--;     }  // decrements the value of number by 1

    cout<<number<<" "; }  } // displays the matching digits

Explanation:

I will explain the program with an example:

Let suppose the number = 90

The if condition evaluate to false because 90 is in the range of 20-98 so the else part executes which has a while loop that works as following:

while(number % 11)

At first iteration:

This while(number % 11) is basically equivalent to :

while(number % 11 != 0)

while(90 % 11)

The % operator is the modulo operator which returns the remainder of the division. So when 90 is divided by 11 the remainder is 2. This is not equal to 0. So the statement under while condition executes:

cout<<number<<" "; This statement displays the number on output screen. Since number = 90 so 90 is printed. " " adds a space with the number

90

Next the value of number is decremented to 1 so number = 89

At second iteration:

while(number % 11) becomes:

while(89 % 11)

When 89 is divided by 11 the remainder is 1. This is not equal to 0. So the statement under while condition executes:

cout<<number<<" "; This statement displays the number on output screen. Since number = 89 so 89 is printed. " " adds a space with the number

90 89

Next the value of number is decremented to 1 so number = 88

At third iteration:

while(number % 11) becomes:

while(88 % 11)

When 89 is divided by 11 the remainder is 0. So the while loop breaks because the condition while(number % 11 != 0) evaluates to false. So the statement in while loop does not execute and program control moves to the following statement:

    cout<<number<<" "; This statement displays that number whose digits match on the output screen with a space. So the output of the entire program is:

90 89 88

The program along with the output using example given in the question i.e. input is 93 is attached in a screenshot.

6 0
3 years ago
Variablesallow us to manipulate data through the ___________.
gladu [14]

Answer:

Reference

Explanation:

Variables provide reference to the stored data value.

For example:

int i = 0;

Here i is a variable of type int with an initial value of 0. i is a reference to this stored value 0. Now if I want to update the data, I can do so using this reference.

i = 1;

Now the reference is used to manipulate the stored data and change it to 1. In a similar manner all updates to the value can be done using the variable reference.

8 0
3 years ago
Waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
True [87]

Answer:

AGGHHHHHHHHHHHHHHHHHHHGHGHHHHHH

Explanation:

8 0
3 years ago
Read 2 more answers
<img src="https://tex.z-dn.net/?f=3x%20-%205%20%3D%203x%20-%207" id="TexFormula1" title="3x - 5 = 3x - 7" alt="3x - 5 = 3x - 7"
xxMikexx [17]

Answer:

x = -1/2

Explanation:

<em>Hey there!</em>

To solve for x we need to simplify the following,

3x - 5 = 7x - 3

-3x to both sides

-5 = 4x - 3

+3 to both sides

-2 = 4x

Divide both sides by 4

-1/2 = x

<em />

<em>Hope this helps :)</em>

6 0
4 years ago
Other questions:
  • When an object is falling because of gravity, the following formulacan be used to determine the distance the object falls in asp
    9·1 answer
  • What is the definition of D1-D4?
    14·1 answer
  • A customer seeks to buy a new computer for a private use at home.The customer primarily needs the computer to use the Microsoft
    8·1 answer
  • How do you invite someone to a conversation on brainly
    14·1 answer
  • Hooollaaaa , todos absolutamente todos quieren borrar esta tarea por que no tiene nada que ver con la materias del colegiooo per
    7·2 answers
  • Why do you think there is a difference between good, clean designs compared to the bad, cluttered designs below?.
    6·1 answer
  • Hãy giúp tôi giảiiii​
    14·1 answer
  • Я люблю есть гнезда петух
    11·1 answer
  • Definition of Computer forensics?
    12·2 answers
  • Select the correct answer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!