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
What does the following code do? Assume list is an array of int values, temp is some previously initialized int value, and c is
BigorU [14]

Answer:

Option D is correct.

Explanation:

Option D is correct because  when the condition  if (list[j] < temp) is tested it only gets true when element in list[] array at <em>jth</em> position is less than the value in <em>temp</em> and after that it increments the value of c by this statement: c++ and so c is incremented from 0 to as much times as much elements in list[] are lesser than temp.

6 0
3 years ago
Read 2 more answers
The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi
Rzqust [24]

Answer:

Answered below

Explanation:

Class BaseballPlayer{

//Instance variables

string name;

int hits;

int bats;

//Constructor

BaseballPlayer (string a, int b, int c){

name = a;

hits = b;

bats = c

}

public void printBattingDetails( ){

System.out.print(name, hits, bats)

}

}

//Demo class

Class BaseballTester{

public static void main (String args []){

BaseballPlayer player = new BaseballPlayer("Joe", 8, 4)

player.printBattingDetails( )

}

}

8 0
3 years ago
Please help,
MAXImum [283]

Answer:Answer I think it might be true Explanation in the Explanation

Explanation: So I think it might be true because Ergonomics is the science of conforming the workplace and all of its elements to the worker, and in the question it says that "How a product relates to the human body", so I think it might be true, Sorry if I got this wrong.

GOOOOOOD LUUUUUCCCCCCKK

8 0
3 years ago
List out 20 output devices ​
GaryK [48]

Answer:

20 Examples Output Devices

Monitor.

Printer.

Audio Speakers.

Headphones.

Projector.

GPS.

Sound Card.

Video Card.

7 0
2 years ago
Read 2 more answers
A database is a collection of integrated and related _____.
ioda
C) files
Because technologys data goes into files
4 0
3 years ago
Read 2 more answers
Other questions:
  • What type of firewall works on the Session layer that creates a connection and allows packets to flow between the two hosts with
    8·1 answer
  • When we focus on stereotypes we may ___________________. a. experience culture shock b. develop ethnocentrism c. unconciously lo
    8·2 answers
  • You create a storyboard at the _____ stage of web development
    15·2 answers
  • You recently upgraded your computer and added an extra 512 MB of RAM. Consequently, you want to increase your swap space by addi
    10·1 answer
  • Internet is for everyone but it wont be if its users cannot protect their privacy and the confidentiality of transactions conduc
    6·1 answer
  • Huan wants to enter the science fair at his school. He has a list of ideas for his project. Which questions could be answered th
    14·1 answer
  • In what stage of an algae or fungi life cycle are they able to reproduce spores?
    10·1 answer
  • New trends, tools, and languages emerge in the field of web technology every day. Discuss the advantages of these trends, tools,
    15·1 answer
  • Erewrxdnnefwn q wedsvd
    6·1 answer
  • Which tab on the Ribbon contains the command to print a publication?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!