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
BartSMP [9]
3 years ago
8

Write a sentinel-controlled while loop that accumulates a set of integer test scores input by the user until negative 99 is ente

red.

Computers and Technology
1 answer:
Masteriza [31]3 years ago
4 0

Answer:

Here is the sentinel-controlled while loop:

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

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

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

int test_score; // declare an integer variable for test scores

//prompts user to enter test scores and type-99 to stop entering scores

cout << "Enter the test scores (enter -99 to stop): ";

cin >> test_score; // reads test scores from user

while (test_score != -99){ // while loop keeps executing until user enters -99

cin >> test_score; } } // keeps taking and reading test scores from user

Explanation:

while loop in the above chunk of code keeps taking input scores from user until -99 is entered. Sentinel-controlled loops keep repeating until a sentinel value is entered. This sentinel value indicates the end of the data entry such as here the sentinel value is -99 which stops the while loop from iterating and taking the test score input from user.

The complete question is that the code should then report how many scores were  entered and the average of these scores. Do not count the end sentinel -99 as a score.

So the program that takes input scores and computes the number of scores entered and average of these scores is given below.

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

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

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

double sum = 0.0;  // declares sum variable to hold the sum of test scores

int test_score,count =0;  

/* declares test_scores variable to hold the test scores entered by user and count variable to count how many test scores input by user */

cout << "Enter the test scores (or -99 to stop: ";

//prompts user to enter test scores and type-99 to stop entering scores

cin >> test_score;  // reads test scores from user

while (test_score != -99){  // while loop keeps executing until user enters -99

count++;  /* increments count variable each time a test cores is input by user to count the number of times user entered test scores */

sum = sum + test_score;  // adds the test scores

cin >> test_score;}  // reads test scores from user

if (count == 0)  // if user enters no test score displays the following message

cout << "No score entered by the user" << endl;

else  //if user enters test scores

//displays the numbers of times test scores are entered by user

cout<<"The number of test scores entered: "<<count;

/* displays average of test scores by dividing the sum of input test scores with the total number of input test scores */

cout << "\n The average of " << count << " test scores: " <<sum / count << endl;}

The program along with its output is attached.

You might be interested in
Design a Visual Logic flowchart for a program that prompts the user to enter ten numbers one at a time. After the user has enter
swat32
N = 0 

<span>1 read x </span>

<span>n = n + 1 </span>

<span>print x </span>

<span>If n > 1, go down to 2 </span>

<span>small = x </span>
<span>large = x </span>

<span>2 If x</= small, then small = x </span>
<span>If x>/= large, then large = x </span>

<span>If n < 12 , go back up to 1 </span>

<span>Print small </span>
<span>Print large </span>
<span>end</span>
8 0
3 years ago
Drag the system component on the left to the device or program that fits with the system component.
Strike441 [17]

Answer:

A. Back up software - Utility software

B. Printer - Device drivers

C. Camera - Firmware

D. Television - Firmware

E. Games console - Firmware

F. Antivirus software - Utility software

G. Disk Cleaner - Utility software

H. Video Card - Device drivers

Explanation:

Computer system components are the physical or hardware and software parts of the device. It is a combination of system software like utility software, device drivers and firmware, application software, and the hardware components and kernel.

4 0
3 years ago
What are the five parts of computer hardware that can be found in most computer systems?
pashok25 [27]

Answer:

processor, primary storage, secondary storage, input devices and output devices

Explanation:

processor, primary storage, secondary storage, input devices and output devices are the five parts of computer hardware that can be found in most computer systems

8 0
3 years ago
Assume courseTitle ="Principles in Information Technology and Computation";
deff fn [24]

Answer:

It saves the position of the first occurrence of "o" to variable something.

Explanation:

The search() method in javascript searches the expression or the string and returns the position of it's first occurrence and if not found it returns -1.

So in the code given above it will search for character o and returns the position of it's first occurrence that is 16 and if there were no o in the string then it would have returned -1.

3 0
4 years ago
Write a Qbasic program to read the value of base and height of a triangle and find its area. ​
Komok [63]

Answer:

The program to this question as follows:

Program:

PRINT "Program: Area of Triangle" 'print message

INPUT "Enter base: ", base 'defining the variable base and input value from the user

INPUT "Enter height:",height 'defining variable height and input a value from user

Area=base*height/2 'formula to calculate Area

PRINT "Area of Triangle:", Area 'print Area

Output:

Program: Area of Triangle

Enter base:   2

Enter height:  3

Area of Triangle: 3

Explanation:

In the above Qbasic program, first, a print function is used to print the message. In the next line, the input function is defined, which uses the "base and height" variable for user input.

Then another variable "Area" is defined that uses user input values to calculate the area of a triangle, and also store its calculated value.  At the last, the print function is used to print Area variable value  

5 0
3 years ago
Other questions:
  • One of the earliest uses of an electronic digital computer involved ________.
    8·1 answer
  • What is grid computing? It is distributed computing where autonomous computers perform independent tasks. It is interconnected c
    12·1 answer
  • Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
    15·1 answer
  • Why is the wizard able to install the printer when an actual print device is not connected to the computer??
    11·1 answer
  • While you work on the customer’s printer, he continues chatting about his network and problems he’s been experiencing. One compl
    14·2 answers
  • Publishers that participate in a display ad network _____ a) get paid each time an advertiser is charged by the ad network for d
    7·1 answer
  • PLS HELP IMEDIATELY!!!!!
    15·2 answers
  • If A = 5 i + j abd B = 2k then A - B in equal to​
    13·1 answer
  • Who prime minister of india​
    9·2 answers
  • You need a(n) _____ to play an mp3 audio file on a desktop or laptop computer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!