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
DENIUS [597]
3 years ago
14

How to write a C++ program that allows a user to enter their rating of the three movies in the Dark Knight Trilogy and then disp

lay each rating entered, the highest rating, the lowest rating, and the average of the ratings??
Computers and Technology
1 answer:
8_murik_8 [283]3 years ago
8 0

The program is an illustration of arrays.

Arrays are used to hold multiple values in one variable.

The program in C++ where comments are used to explain each line is as follows:

#include <iostream>

using namespace std;

int main(){

   //This declares an array of three elements for the three ratings

   int ratings[3];

   //This initializes the sum of the ratings to 0

   int total = 0;

   //The following iteration gets input for the three ratings

   for(int i = 0; i<3;i++){

       cin>>ratings[i];

       //This calculates the sum of all inputs

       total+=ratings[i];

   }

   //This declares and initializes the lowest and the highest ratings

   int lowest = ratings[0], highest = ratings[0];

   //This iterates through the array

   for(int i = 1; i<3;i++){

       //The following if condition determines the lowest rating

       if (lowest > ratings[i]){    lowest = ratings[i];        }

       //The following if condition determines the highest rating

       if (highest < ratings[i]){            highest = ratings[i];        }

   }

   //This prints the output header

   cout<<"The ratings are: ";

   //The following iteration prints the three ratings

   for(int i = 0; i<3;i++){

       cout<<ratings[i]<<" ";   }

   //The prints the highest ratings

cout<<endl<<"Highest: "<<highest<<endl;

   //The prints the lowest rating

   cout<<"Lowest: "<<lowest<<endl;

   //The prints the average rating

cout<<"Average: "<<total/3<<endl;

   return 0;

}

At the end of the program, the ratings entered, the highest rating, the lowest rating, and the average of the ratings are printed.

See attachment for sample run

Read more about similar programs at:

brainly.com/question/13261254

You might be interested in
Which of the following provides astronomical evidence for the age of the earth?
Anestetic [448]

A. movement of galaxies

3 0
3 years ago
Choose the best technology device for the
Oxana [17]

Answer:

Desktop computer with 2 screens

Explanation:

All graphices designers need the most screen space possible

8 0
3 years ago
A laptop computer manufacturer would consider the computer's processor chip to be a(n) ______ cost.
erastovalidia [21]

Answer:

direct material

Explanation:

if you need anymore help let me know

3 0
3 years ago
I need help with humans need not apply for codeing
vampirchik [111]

Answer:

huge\color{blue}\boxed{The}\huge\color{pink}\boxed{Points

3 0
2 years ago
Read 2 more answers
Lonic compounds are also known as <br> a. salts <br> b. valence <br> c.organic <br> d.elements
shutvik [7]
I'm not quite sure but it maybe b
6 0
3 years ago
Read 2 more answers
Other questions:
  • What CLI command can be issued in CentOS 7 to help you to see every "hop" that a connection makes, including all of the switches
    13·1 answer
  • The arrow next to All Programs indicates _____. that this item cannot be selected that this was the most recently used item the
    7·2 answers
  • Match the terms with their definitions.
    5·2 answers
  • Match the number in the picture to the correct Excel interface part. Each number is only used one time.
    11·1 answer
  • write a function that takes a string as parameter, return true if it’s a valid variable name, false otherwise. You can use keywo
    6·1 answer
  • If you need assistance with your I-20 which phone number at UC would you call?
    10·1 answer
  • What is the document that provides basic guidance and regulatory requirements for derivative classification
    9·1 answer
  • The best way to safeguard your document is to save it
    11·1 answer
  • LaShawn would like to post photos in a social media app, but the program needs to be modified in order to display a greater vari
    12·2 answers
  • Personal statements School leaver
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!