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

  • Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0...

    Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0 and 100). The program should store the numbers in an array and then display the following information: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Your program should consist of the following: Module main. Accepts input of numbers and assigns them to an array....

  • // This program will read in a group of test scores (positive integers from 1 to...

    // This program will read in a group of test scores (positive integers from 1 to 100) // from the keyboard and then calculate and output the average score // as well as the highest and lowest score. There will be a maximum of 100 scores. // #include <iostream> using namespace std; float findAverage (const int[], int); // finds average of all grades int findHighest (const int[], int); // finds highest of all grades int findLowest (const int[], int); //...

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

  • Please write in java program Write an application that generates 100 random integers between 1 and...

    Please write in java program Write an application that generates 100 random integers between 1 and 75 and writes them to a file named "file_activity.txt". Read the data back from the file and display the following: The sum of the numbers in the file The average of the numbers in the file The numbers in the file in increasing order To sort an array: int[] arr = new int[20]; Arrays.sort(arr); -- this sorts an array To sort an ArrayList: ArrayList<Integer>...

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

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