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
Mashcka [7]
4 years ago
9

Calculate the average of a set of grades and count

Computers and Technology
1 answer:
Natasha_Volkova [10]4 years ago
4 0

Answer:

// Scanner class is imported so that the program can can user input

import java.util.Scanner;

// class Solution is defined

public class Solution {

//main method which begin program execution is defined

public static void main(String args[]) {

// Scanner object scan is defined to receive input fromkeyboard

Scanner scan = new Scanner(System.in);

// A prompt is display to the user asking for number of grade

System.out.println("How many grade do you want to enter");

// The user input is assigned to numOfGrade

int numOfGrade = scan.nextInt();

// An array of integer called gradeArray is declared

// it has numOfGrade as length

int[] gradeArray = new int[numOfGrade];

// for-loop that prompt the user to enter grade to fill the gradeArray

for(int i = 0; i < numOfGrade; i++){

System.out.println("Enter a grade: ");

int grade = scan.nextInt();

gradeArray[i] = grade;

}

// sun variable is declared and initialized to 0

int sum = 0;

// numOfFail is declared and initialized to 0

int numOfFail = 0;

// for-loop through the gradeArray that add all element

// it also increase the counter for numOfFail if grade is < 70

for(int j = 0; j < gradeArray.length; j++){

sum += gradeArray[j];

if (gradeArray[j] < 70){

numOfFail++;

}

}

// aveargeGrade is calculated

int averageGrade = (sum / numOfGrade);

// numOfFail is displayed to the user

System.out.println("Number of fail is: " + numOfFail);

// the averageGrade is also displayed.

System.out.println("Average grade is: " + averageGrade);

}

}

Explanation:

The code is well commented and written in Java.

You might be interested in
write a java program that prompts the user to enter scores (each number an integer from 0 to 10) and prints the following output
Vladimir [108]

Answer:

Explanation:

The following is written in Java. It continues asking the user for inputs until they enter a -1. Then it saves all the values into an array and calculates the number of values entered, the highest, and lowest, and prints all the variables to the screen. The code was tested and the output can be seen in the attached image below.

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int count = 0;

       int highest, lowest;

       ArrayList<Integer> myArr = new ArrayList<>();

       while (true) {

           System.out.println("Enter a number [0-10] or -1 to exit");

           int num = in.nextInt();

           if (num != -1) {

               if ((num >= 0) && (num <= 10)) {

                   count+= 1;

                   myArr.add(num);

               } else {

                   System.out.println("Wrong Value");

               }

           } else {

               break;

           }

       }

       if (myArr.size() > 3) {

           highest = myArr.get(0);

           lowest = myArr.get(0);

           for (int x: myArr) {

               if (x > highest) {

                   highest = x;

               }

               if (x < lowest) {

                   lowest = x;

               }

           }

           System.out.println("Number of Elements: " + count);

           System.out.println("Highest: " + highest);

           System.out.println("Lowest : " + lowest);

       } else {

           System.out.println("Number of Elements: " + count);

           System.out.println("No Highest or Lowest Elements");

       }

   }

}

4 0
3 years ago
Which of the following describes cloud computing?​
slamgirl [31]

Answer:

Cloud computing is  the on-demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. The term is generally used to describe data centers available to many users over the Internet.

4 0
3 years ago
To save the changes to the layout of a table, click the Save button on the _____.
kari74 [83]
Quick access toolbar :)))))))))
7 0
3 years ago
Which excel feature makes it easy to copy and paste formulas in multiple cells?.
timama [110]

Answer:

Ctrl + R - Copy a formula from the cell to the left and adjusts the cell references. For example, if you have a formula in cell A2 and you want to copy it to cell B2, select B2 and press Ctrl + R. Tip. Both of the above shortcuts can be used to copy formulas to multiple cells too.

Explanation:

8 0
2 years ago
PLSSSSSS HELP ASAP<br><br> What story does the game Senet tell?
kkurt [141]

Answer:

In the New Kingdom, the game senet, which means "passing," became associated with the journey to the afterlife. Some of the squares of the game corresponded to the hazards a person might meet on their journey to the afterlife, while other squares helped the players.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • A database on a mobile device containing bands, sub-bands and service provider IDs allowing the device to establish connection w
    9·1 answer
  • Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
    13·2 answers
  • Implement the function is_maxheap which takes a list of integers and returns True if the list represents a valid max-heap, and F
    6·1 answer
  • Pen registers and trap-and-trace devices are not considered forms of searches and do not need probable cause and a court order b
    10·1 answer
  • You are the network adminstrator for your company your network consists of two active directory domains research.westsim.local a
    12·1 answer
  • In information security, a specification of a model to be followed during the design, selection, and initial and ongoing impleme
    5·1 answer
  • $100 to whoever finishes my assignment by june 1st
    11·1 answer
  • Raw materials have two basic types what are the 2?
    11·2 answers
  • 1
    10·1 answer
  • If a company gave you a free version of their software and encouraged you to try and improve it and share it with the only commu
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!