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
Rasek [7]
3 years ago
13

write a java program that prompts the user to enter scores (each number an integer from 0 to 10) and prints the following output

: how many scores entered the highest score the lowest score the average of all the scores the average with the highest and lowest score not counted if the user enters less than 3 scores print an error message instead of the output above
Computers and Technology
1 answer:
Vladimir [108]3 years ago
4 0

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");

       }

   }

}

You might be interested in
Consider the following code: String word [] = {"algorithm", "boolean", "char", "double"}; for ( int i =0; i &lt; word.length/2;
KiRa [710]

Answer:

{"double", "char", "char", "double"} will be stored in word.

Explanation:

Given the word is an array of four strings,  {"algorithm", "boolean", "char", "double"}. Hence, the length of the word array is 4.

The for-loop will only run for two iterations due to i < word.length/2, with i = 0 (first loop) and i = 1 (second loop).

In the first loop,  

  • word[word.length - 1 - i]  =  word[4 - 1 - 0]  = word[3]  = "double"
  • Hence, the string "double" will be assigned to word[0] and overwrite "algorithm"

In the second loop,

  • word[word.length - 1 - i]  =  word[4 - 1 - 1]  = word[2]  = "char"
  • Hence, the string "char" will be assigned to word[1] and overwrite "boolean"

At last, the word array will hold {"double", "char", "char", "double"}

8 0
4 years ago
Read 2 more answers
Which of the following factors will have the greatest impact on your credit score?1. Length of credit history 11. Payment histor
irinina [24]
I believe your payment history would have the greatest impact on your credit score
4 0
4 years ago
What does pagination mean in Microsoft Word?
marin [14]

it means to alt f4 then that would help so it can eat the microscope then have it digested

5 0
3 years ago
Read 2 more answers
An ellipse (three dots) following a menu item indicates that
Mariulka [41]

Answer:

Correct answer is

clicking on item will display a dailogbox/ more options

Explanation:

In web site menus have limited space.To add all items menus are grouped in categories and only category names are shown while there subsets are displayed in a drop down list upon hovering on them.

Some time designer user three dot indication which indicates there are more options available in a hidden side bar or dialog menu which opens upon clicking the ellipse.

3 0
3 years ago
Read 2 more answers
Why would a virtual machine be useful in a school? It provides a completely secure connection to the internet. Students can coll
Stels [109]
They can learn more and also it’s faster
5 0
3 years ago
Other questions:
  • The ____ loop stops when the loop has processed every element in an array.?
    7·1 answer
  • Data mining is defined as: a)Separating data and programs such that each can be changed without changing the other b)Allowing ma
    5·1 answer
  • An intranet that is partially accessible to authorized people outside the business or organization is known as an
    7·2 answers
  • List two reasons why buying a computer is no easy task?
    7·1 answer
  • In order to recover from an attack on any one server, it would take an estimated 14 hours to rebuild servers 1, 2, 3, and 4 and
    6·1 answer
  • Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the secon
    11·1 answer
  • What is the output of executing the code segment?
    7·1 answer
  • Which of the following are used to classify plutons
    14·1 answer
  • On a wireless network use _____ to ensure that only authorized client computers are able to access the wireless network.
    10·1 answer
  • 5.11 LAB: Print string in reverse [JAVA]:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!