Question
C++

Write a program to input eight integer numbers into an array named grade. As each number is input, add the number into a tota

C++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

int sum = 0;

int grade[8];

int inp;

cout << "\nYou must enter 8 scores and the program will display all your scores along with the average score.\n";

for(int i = 0; i < 8; i++)

{

cout << "Enter score " << (i + 1) << ": ";

cin >> inp;

while(inp <= 0 || inp > 100)

{

cout << "Score must be between 1 and 100!\n\n";

cout << "Enter score " << (i + 1) << ": ";

cin >> inp;

}

grade[i] = inp;

sum += inp;

}

double average = ((double)sum) / 8.00;

cout << "\nYOUR SCORES AND AVERAGE:\n------------------------\n";

for(int i = 0; i < 8; i++)

{

cout << "Score " << (i + 1) << ": " << grade[i] << endl;

}

cout << setprecision(2) << fixed << "Average = " << average << endl;

return 0;

}

******************************************************************* SCREENSHOT ********************************************************

clang version 7.0.0-3-ubuntu0.18.04.1 (tags/RELEASE 700/final ) clang++-7 -pthread -std -c++11 -o main main.cpp /main You mus

Add a comment
Know the answer?
Add Answer to:
C++ C++ Write a program to input eight integer numbers into an array named grade. As...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a c++ program that does the following Create an integer array of size 30. Assign...

    Write a c++ program that does the following Create an integer array of size 30. Assign -1 to each location in the array indicating that the array is empty. Populate half of the array with random integer values between 100 and 500 inclusive. Use the following formula in order to hash and store each number in its proper position/location. Generated Number Table Size: Should a collision occurs, use linear probing to find next available position location. Use the following probing...

  • Write a program in C++ that reads in integer numbers from a file called scores.txt until...

    Write a program in C++ that reads in integer numbers from a file called scores.txt until the sentinel value -999 is read. The program should then output the total and average of the numbers read and output each of the numbers incremented by the overall average to a file called or scoresout.txt along with the sentinel value of -999 at the end So if 10, 20, 30 and -999 are read in then the program would display a total of...

  • Write a program in C that creates an array of 100 random numbers from 0-99. The...

    Write a program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum.  It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...

  • C++ programming please Write a program that will display random numbers in order from low to...

    C++ programming please Write a program that will display random numbers in order from low to high. 1. Declare an integer array of size 100. Ask the user how many numbers to work with (n). It can be less than 100. 2. Generate random numbers from 10 to 50. 3. Write the random numbers to an output file named random.dat. Close the file. 4. Open random.dat for input and read the data values into your array. Pass your array to...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Write a Java program with a single-dimension array that holds 11 integer numbers and sort the...

    Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish. algorithm (either flowchart or pseudocode) that you will use to write the program Step 1. Create an Place the algorithm in a Word document. 6. Ste the Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1....

  • Write a program that first reads an integer for the array size, then reads numbers into...

    Write a program that first reads an integer for the array size, then reads numbers into the array, computes their average, and finds out how many numbers are above the average. Make sure to include pointer syntax. Example output: Enter array size: 10 10 random numbers between 1 and 10 generated are: 2 8 5 1 10 5 9 9 3 5 The average is: 5.7 Number of items above the average = 4 C++ Code only.

  • Write a Java program named BSTree.java that will: 1) Generate 20 random integer numbers ranging from...

    Write a Java program named BSTree.java that will: 1) Generate 20 random integer numbers ranging from 1-99. 2) Build a Binary Search Tree using this set of numbers. Write the add method. 3) After building the tree, display the data into three formats: prefix order, infix order, and postfix order. 4) Write a method to delete an element from the Binary Search Tree. First search the item in your TREE and then delete it.

  • Write a C program requesting the user to input two integer numbers and then requesting the...

    Write a C program requesting the user to input two integer numbers and then requesting the user to either add, subtract, or multiply the two numbers (choose 0 to add, 1 to subtract, or 2 to multiply. Declares three separate functions for these choices to come after main(). Program needs to use a pointer to these three functions to perform the requested action. Must print to output.

  • Write a C++ program that simulates a lottery game. Your program should use functions and arrays....

    Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT