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]
2 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]2 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
The term information technology was first used what year?
skelet666 [1.2K]

Answer:

1958

Explanation:

The term was first published in the 1958 Harvard Business Review when authors Harold J. Leavitt and Thomas C. Whisler said “the new technology does not yet have a single established name. We shall call it Information Technology.”

7 0
2 years ago
Read 2 more answers
How is the Microsoft Word 2013 window organized?
Alenkasestr [34]
The answer is (A): with contextual tabs for major groupings of editing features and ribbons with specific groupings to organize commands.


Contextual tab or tabs are hidden menu that appears when objects like images or texts are selected in programs like MS Word 2013. They typically contain one or more commands applicable to a selected text or object only. They are there in the Ribbon when you need them and disappear when you do not need them anymore. They are basically used for major groupings of editing features.
A ribbon on the other hand help users understand how commands are used directly and efficiently. It organizes a program’s features into a series of tabs.




6 0
3 years ago
Read 2 more answers
What is a computer dedicated to a single function, such as a calculator or computer game? A. TabletB. PDAC.ApplianceD. Minicompu
viktelen [127]

Answer:

C. Appliance.

Explanation:

When a device or machine performs a single function or task, it is commonly referred to as an appliance. Examples of such is an iron, a calculator, a computer game, washing machines, refrigerators, e.t.c

<em>A Personal Digital Assistant (PDA)</em>, is a device, mostly mobile and handheld, that combines various computing features such as telephoning and networking. An example is a tablet. A PDA performs more than a single function.

<em>Minicomputer</em> is a computer usually small in physical size, that is midway in capabilities and support, between a microcomputer and a mainframe computer. An example is also a tablet and our smartphones. Minicomputers are also dedicated to various functions rather than a single function.

In summary, the option that best describes the situation in the question is an appliance.

<em>Hope this helps!</em>

6 0
3 years ago
Spam and i report
defon

Answer:

option d is the correct answer

8 0
2 years ago
Read 2 more answers
If a program compiles fine, but it produces an incorrect result, then the program suffers from _______________.
tatiyna
In my answer I am making an assumption that there is no runtime error, if there is then the error is “a run-time error”.

The answer is the program suffers from a Logic Error
5 0
3 years ago
Other questions:
  • Driving while wearing headphones or earphones
    12·2 answers
  • During an experiment, if you purpose change the temperature to test a hypothesis the temperature is called what??
    6·1 answer
  • In an inheritance situation, the new class that you create from an existing class is known as the:
    5·1 answer
  • How do you get 99 points on sunny meadows simulation?
    6·2 answers
  • A network administrator is required to upgrade wireless access to end users in a building. To provide data rates up to 1.3 Gb/s
    12·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • What is the nearest ten cents of 453.56
    5·1 answer
  • Any device that uses light to read and write information.
    9·2 answers
  • Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the
    6·1 answer
  • If a machine cycle is 2 nanoseconds , how many machine cycles occur each second?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!