Question

1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores...

1.

Write a program that randomly generates 10 whole numbers between 0 and 100 and stores them into an array. The program then calculates the average and displays the average and the numbers that are above the average. Use loops where needed. Must be stored in an array. Must be done using C++.

2.

Write a program that reads 8 student scores, between 0 and 100, finds the best score, and then assigns grades based on the following scheme. Must use loops where needed. Must be done using C++.

Grade is A if score >= best – 10

Grade is B if score >= best – 20

Grade is C if score >= best – 30

Grade is D if score >= best – 40

Grade is F otherwise.

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

1.)

import java.util.*;

public class Average {
    public static void main(String[] args)
    {
        Random r = new Random();
        int nxt;
        int[] arr = new int[10];
        float avg = 0;
      
        System.out.println("\nRandomly generated 10 numbers are :\n");
        for(int i = 0; i < 10; i++)
       {
           nxt = r.nextInt(100);
           arr[i] = nxt;
           avg += nxt;
          
           // Printing the random Number
           System.out.print(nxt+" ");
       }
       avg = avg/10;
       System.out.printf("\n\nAverage is %.2f\n", avg);
      
        System.out.println("\nNumbers above average are :");
        for(int i = 0; i < 10; i++)
       {
           if(arr[i] > avg)
               System.out.print(arr[i]+" ");
       }
       System.out.println("\n");
   }
}

SCRRENSHOT

OUTPUT

ANYTHING NOT UNDERSTOOD COMMENT DOWN, THANK YOU.

ACCORDING TO HOMEWORKLIB RULES I AM RESTRICTED TO ANSWER SINGLE QUESTION PER POST. HENCE YOU NEED TO POST OTHER QUESTIONS IN ANOTHER POST. SORRY FOR INCONVIENCE.

Add a comment
Know the answer?
Add Answer to:
1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores...
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
  • C++ language Write a program that 1. generates a random integer between 100 and 1000, call...

    C++ language Write a program that 1. generates a random integer between 100 and 1000, call the number N 2. reads a file name from the keyboard 3. opens a file for output using the file name from step 2 4. generates N random numbers between 1 and 100 and writes them to the file from step 3 5. closes the file 6. opens the file from steps 3, and 4 for input 7. reads the numbers from the file...

  • Write a program in C language that reads scores and id numbers from a file, finds...

    Write a program in C language that reads scores and id numbers from a file, finds the average score, and assigns each student a grade based on the following rules: Each score > average + 20 gets an A Each score between average + 10 and average + 20 gets a B Each score between average - 10 and average + 10 gets a C Each score between average - 20 and average - 10 gets a D Each score...

  • Task 1 : Write a Java program that prompts for and reads 10 integers from the...

    Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.

  • C++ Write a program that reads the number of students in the class, then reads each...

    C++ Write a program that reads the number of students in the class, then reads each student's name and his/her test score. Print out each student name, test score and grade, and the average score of the whole class. The program must use vectors and loops for the implementation. The grades are determined as follows: A >= 90; 80 <= B < 90; 70 <= C < 80; 60 <= D < 70; F < 60.

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • Write a program that generates an array of one hundred random integers between 0 and 9...

    Write a program that generates an array of one hundred random integers between 0 and 9 and displays the count of each number. C programming

  • Write a program using "C" in visual studio that: A. Has a function (input()) that allows...

    Write a program using "C" in visual studio that: A. Has a function (input()) that allows the user to enter a list of 10 scores and stores them in an array. B. Has a function (result()) then assigns grades based on the following sheme: 21 Write a program that a Has a function (iaoutO) that allows the user to enter a list of 10 scores and stores therm in an array b. Has a function (resultil then assigns gracdes besed...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • 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.

  • Using the following parallel array and array of vectors: // may be declared outside the main...

    Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS =3; // may only be declared within the main function string Students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Write a C++ program to run a menu-driven program with the following choices: 1) Display the grades 2) Add grade 3) Remove grade for all students for a selected assignment 4) Display Average for each student 5) Display the name of...

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
ADVERTISEMENT