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
harkovskaia [24]
3 years ago
12

Design and implement a program that reads a series of 10 integers from the user and prints their average. Read each input value

as a string, and then attempt to convert it to an integer using the Integer.parseInt method. If this process throws a NumberFormatException (meaning that the input is not a valid number), print an appropriate error message and prompt for the number again. Continue reading values until 10 invalid integers have been entered.
Computers and Technology
1 answer:
irina [24]3 years ago
3 0

Answer:

Explanation:

The following program was written in Java. It creates a loop that asks the user for numbers. If it can convert it to an integer it accepts it and adds it to the sum variable otherwise it ouputs that it is not a valid number. Once all 10 integers are added it prints the Average of the values entered.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int count = 0;

       int sum = 0;

       while (count != 10) {

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

           String answer = in.nextLine();

           try {

               int intAnswer = Integer.parseInt(answer);

               sum += intAnswer;

               count += 1;

           } catch (NumberFormatException e) {

               System.out.println("Not a valid number.");

           }

       }

       int average = sum / count;

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

   }

}

You might be interested in
How to drive more website traffic?
lidiya [134]

Hello there,

How to drive more website traffic?

Answer: Advertise

8 0
4 years ago
What changes do you need to make to the algorithm to take as first input the numbers to be compared
Alenkinab [10]

Answer:

Explanation:

The constant function is useful in algorithm analysis, because it characterizes the number of steps needed to do a basic operation on a computer, like adding two numbers, assigning a value to some variable, or comparing two numbers. Executing one instruction a fixed number of times also needs constant time only.

6 0
3 years ago
What would be some reasons to change the default page<br> encoding?
madam [21]

Answer:

Synchronization with the document for one reason or another

5 0
3 years ago
Can the charger of my laptop get infected with viruses also when it was connected to it?​
Ganezh [65]

Answer:

Technically… yes. Because if the charging port is the same as a USB/etc connector port, then it can travel over that.

Explanation:

3 0
2 years ago
Are our current copyright policies helping society or hurting society? i need help
Oksanka [162]

Answer:

helping society

Explanation:

it can help you to protect your works and creativity and brilliant ideas from liars and cheaters and frauds

5 0
3 years ago
Other questions:
  • A university wants to install a client-server network. Which feature do you think is important for them as they set up the netwo
    7·1 answer
  • Using information from the lesson, explain how new technologies change your experience as a consumer.
    5·2 answers
  • For an external usb hard drive attached to a computer, which is more suitable: a writethrough cache or a block cache
    14·2 answers
  • A small company is requesting a quote to refresh its wireless network. The company currently runs 60 autonomous APs and has plan
    13·1 answer
  • Create an application for a library and name it FineForOverdueBooks. TheMain() method asks the user to input the number of books
    7·1 answer
  • What is a written or electronic document that outlines etiquette policies for using networks and network resources?
    8·1 answer
  • Would an artificial intelligence come into existence anytime in the next 30 years?
    8·1 answer
  • Write a program that reads a file that contains only integers, but some of the integers have embedded commas, as in 145,020. The
    10·1 answer
  • Play station account
    12·2 answers
  • Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It s
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!