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
Def find_max(nums: [int]) -&gt; int:
SIZIF [17.4K]

Answer:

The program in recursion is:

def find_max(nums):

    if len(nums) == 0:

         return "None"

    elif len(nums) == 1:

         return nums[0]

    else:

         return max(nums[0],find_max(nums[1:]))

Explanation:

This line defines the function

def find_max(nums):

This checks if the list is empty.

    if len(nums) == 0:

If yes, it returns "None"

         return "None"

If the list has just one element

    elif len(nums) == 1:

It returns the only element as the maximum

         return nums[0]

If the list has numerous elemente

    else:

The maximum is determined recursively

         return max(nums[0],find_max(nums[1:]))

To the (b) part:

<em>This program does not necessarily need to be done recursively because the max built-in function can be used to determine the maximum of the list in just one line of code and it is more efficient.</em>

8 0
3 years ago
In addition to MLA, what are some other widely used style guides? Check all that apply.
Lostsunrise [7]
APA and Chicago manual of style :D
6 0
3 years ago
Read 2 more answers
What is occurring when an attacker manipulates commonplace actions that are routinely performed in a business?
serg [7]

Answer:

Vulnerable business processes, also called business process compromise (BPC), occurs when an attacker manipulates commonplace actions that are routinely performed.

4 0
3 years ago
, , ,g d,t ,dt m,dt ymtd
maks197457 [2]

Answer:ummm me confused

Explanation:

4 0
3 years ago
Which navigation icon would you click on to add a new Contact?
Sauron [17]
The answer would be people
3 0
3 years ago
Read 2 more answers
Other questions:
  • You are tasked with setting up an employee’s computer.Instead of a new computer,she will be using a computer with an older opera
    11·2 answers
  • Charges of the opposite tend to repel each other.
    9·2 answers
  • In the context of information systems, which of the following is a disadvantage of prototyping? a. A prototype is more difficult
    8·1 answer
  • Based on your learning this week, consider rules, policies, and procedures. Technicians are often eager to just get started on a
    10·1 answer
  • Kindly answer in Just 7,8 lines please
    7·1 answer
  • You easily can give slides in a presentation a professional and integrated appearance by using a placeholder.
    11·1 answer
  • What is a common citation style used by students for English classes?
    5·1 answer
  • 8.10 Code Practice Question 3
    6·1 answer
  • Your friends are having difficulties with their computer setups. Can you suggest a way to help each friend?
    5·1 answer
  • which command entered without arguments is used to display a list of processes running in the urrent shell
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!