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]
2 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]2 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
An insurance company utilizes SAP HANA for its day-to-day ERP operations. Since they can’t migrate this database due to customer
hichkok12 [17]

Answer: An Internet-routable IP address (static) of the customer gateway's external interface for the on-premises network

Explanation:

Based on the information given, an Internet-routable IP address (static) of the customer gateway's external interface for the on-premises network need to be configured outside of the VPC for them to have a successful site-to-site VPN connection.

The Internet-routable IP address will be used in the identificatiob of each computer through the use of the Internet Protocol for the communication over a network.

3 0
3 years ago
Why are there so many problems with drivers?
podryga [215]

D. hope this helped!!!!!

5 0
3 years ago
What is the difference between keywords and identifiers in c++ ?
prohojiy [21]
Keywords are the reserved words of a language.Identifiers are the user defined names of variable, function and labels. Hope that this helped
3 0
3 years ago
Wat is the difference between primary storage, secondary storage, and off-line storage
Hitman42 [59]
Primary storage would be downloads and whatever goes directly to your Dropbox or something like that. Secondary storage would also be downloads, but it would be the things that go to your hard drive, and lastly, off-line storage is storage on things like Flash Drives or CD-ROMs.
6 0
3 years ago
Which of the following is an appropriale way to declinc an offer in a<br>professional environment?​
alina1380 [7]
If you’re looking for an exact answer, we weren’t given any options, but in my personal experience just explain that you appreciated them taking their time out of their day and say that you’re no longer interested in their offer.
5 0
3 years ago
Read 2 more answers
Other questions:
  • A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
    13·1 answer
  • The acronym LAH stands for
    14·2 answers
  • What is the full form of bcc please tell​
    15·2 answers
  • dam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correct
    9·1 answer
  • Will mark brainliest! What does this code do? What kind of code is this called?
    15·1 answer
  • Can a result that contains road maps for European countries have a highly meets rating
    12·1 answer
  • Transborder data flow (TDF) restricts the type of data that can be captured and transmitted in foreign countries. True or False
    12·1 answer
  • When creating any digital work, what is the MOST important thing to remember?
    7·1 answer
  • Please help ASAP! will mark brianliest! 30 points!
    14·1 answer
  • What is e banking effects
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!