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
VladimirAG [237]
3 years ago
12

SummaryIn this lab, you complete a partially prewritten Java program that uses an array.The program prompts the user to interact

ively enter eight batting averages, which the program stores in an array. The program should then find the minimum and maximum batting average stored in the array as well as the average of the eight batting averages. The data file provided for this lab includes the input statement and some variable declarations. Comments are included in the file to help you write the remainder of the program.Instructions1.Ensure the file named BattingAverage.java is open.Write the Java statements as indicated by the comments.Execute the program by clicking "Run Code." Enter the following batting averages: .299, .157, .242, .203, .198, .333, .270, .190. The minimum batting average should be .157, and the maximum batting average should be .333. The average should be .2365.import java.util.Scanner;public class BattingAverage{public static void main(String args[]){Scanner s = new Scanner(System.in);// Declare a named constant for array size here.// Declare array here.// Use this integer variable as your loop index.int loopIndex;// Use this variable to store the batting average input by user.double battingAverage;// String version of batting average input by user.String averageString;// Use these variables to store the minimim and maximum batting averages.double min, max;// Use these variables to store the total and the average.double total, average;// Write a loop to get batting averages from user and assign to array.System.out.println("Enter a batting average: ");averageString = s.nextLine();battingAverage = Double.parseDouble(averageString);// Assign value to array.// Assign the first element in the array to be the minimum and the maximum.min = averages[0];max = averages[0];// Start out your total with the value of the first element in the array.total = averages[0];// Write a loop here to access array values starting with averages[1]// Within the loop test for minimum and maximum batting averages.// Also accumulate a total of all batting averages.// Calculate the average of the 8 averages.// Print the averages stored in the averages array.// Print the maximum batting average, minimum batting average, and average batting average.System.exit(0);}{
Computers and Technology
1 answer:
Andrej [43]3 years ago
8 0

Answer:

The complete program is as follows:

import java.util.Scanner;

public class Main{

   public static void main(String args[]){

       Scanner s = new Scanner(System.in);

       final int lent = 8;

       Double averages[] = new Double[lent];

       int loopIndex;

       double battingAverage;

       String averageString;

       double min, max;

       double total, average;

       for(loopIndex = 0;loopIndex<lent;loopIndex++){

       System.out.print("Enter a batting average: ");

       averageString = s.nextLine();

       battingAverage = Double.parseDouble(averageString);

       averages[loopIndex] = battingAverage;        }

       min = averages[0];max = averages[0];

       total = averages[0];

       for(loopIndex = 1;loopIndex<lent;loopIndex++){

       if(averages[loopIndex]>=max){

           max = averages[loopIndex];        }

       if(averages[loopIndex]<=min){

           min = averages[loopIndex];        }

       total+=averages[loopIndex];        }

       battingAverage = total/8;

       for(loopIndex = 0;loopIndex<lent;loopIndex++){

       System.out.println(averages[loopIndex]+" ");        }

       System.out.println("Average: "+battingAverage);

       System.out.println("Minimum: "+min);

       System.out.println("Maximum: "+max);

       System.exit(0);

       }}

Explanation:

See attachment for complete program with comments

Download txt
You might be interested in
Which of the following SNSs has been associated with art work display?
amid [387]
Hoi!

I would say DeviantArt, since that is the world's largest social website dedicated to displaying artwork.
7 0
3 years ago
Read 2 more answers
*When a computer programmer is finished writing or developing a program, what has to happen first before the computer can unders
Alenkinab [10]

Answer:

C. The source code has to be translated into object code.

5 0
3 years ago
Discuss the five challenges that limit the use of computer in remote places in Africa​
Alchen [17]

The first challenge is that there is not electric conection.So the computer won't be able to function.Also there will be noone who will be able to use it due to the lack of education.Plus there will not be internet connection , limitting the abilities of the computer to the very basics.In addition there will not be any tools or spare parts in order to fix a computer.Finally even if thete were spare parts there woul not be someone able to gix the computer.

I hop I was helpful.Let me know if you need anything else.

3 0
3 years ago
You can use a(n) ____ to visually separate related controls from other controls on the form.
maksim [4K]

Answer:

The correct answer to the following question will be Group Box.

Explanation:

Group Box:

  • A type container that contains many types of controls that are usually related to each other in the form.
  • It usually provides the identified grouping for other controls.
  • used for the subdivision of the forms.
  • Separation of the controls can be done with the help of grouping by group box.

5 0
3 years ago
Computer viruses and coding books
timofeeve [1]
Is there a picture to go along with this? I don’t see one and an willing to help!
3 0
2 years ago
Other questions:
  • SOMEONE PLEASE HELP ASAP!!
    14·2 answers
  • How can i repair computer processor?
    12·1 answer
  • A network administrator is required to upgrade wireless access to end users in a building. To provide data rates up to 1.3 Gb/s
    12·1 answer
  • Which of the following statements is false? Question 4 options: By convention class names begin with an uppercase letter, and me
    8·2 answers
  • Which describes the hypothesis of an experiment? the variable changed by the experimenter/ the quantity that must remain constan
    9·1 answer
  • A function is executed when it is
    7·1 answer
  • A tornado destroyed many
    6·2 answers
  • If there are 18 people in your class and you want to divide the class into programming teams of 3
    7·1 answer
  • A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in
    15·1 answer
  • Which of the following is not a component of Power BI?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!