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
The first computer (the eniac was how big
sattari [20]
The first computer is the Eniac which was 50 tons!
3 0
3 years ago
Consider the following code which deletes all the nodes in a linked list. void doublyLinkedList::destroy() { nodeType *temp; //p
Lera25 [3.4K]

Answer:

The answer is "delete temp;".

Explanation:

  • In the given code a class "doublyLinkedList" is defined that contains a method that is destroy(). This code uses a scope resolution operator to define the method outside the class.
  • To access this method write return type of function then class name:: (use scope resolution operator) and function name.
  • In this function, nodeType temp is a pointer variable that is used to delete the node.
  • In method definition, a loop is declared that check value that is first not equal to nullptr. which means the first node is not equal to null. In this loop, a temp variable holds the first variable value and the first variable value is holding another variable value and then use the "delete temp" statement to delete a node in the list.
  • Outside a loop, the last variable holds nullptr variable value and the count variable assigns a value that is 0.
5 0
3 years ago
The part of the computer that contains the brain or central processing unit is also know as the
mart [117]
The part of the computer that contains the brain is called the motherboard.
3 0
3 years ago
Read 2 more answers
Write smallest to largest: Byte, bit, MB, PB, GB, nibble
OlgaM077 [116]

Answer:

  1. bit
  2. nibble
  3. byte
  4. MB
  5. GB
  6. PB

Explanation:

this is it!!!

3 0
3 years ago
Read 2 more answers
Which member of the restaurant and food/beverage service career is mostly likely to plan menus and direct worker
kumpel [21]

What are the options for the question

5 0
3 years ago
Read 2 more answers
Other questions:
  • There are many differenttypes of models, but an individual DSS can consist of onlyone.
    15·1 answer
  • During an experiment, if you purpose change the temperature to test a hypothesis the temperature is called what??
    6·1 answer
  • What to buy instead of the hp chromebook 13
    15·1 answer
  • A service provider, hardware, and web browser are needed to connect to __________.
    8·2 answers
  • Front and rear camber and toe settings are being adjusted during a four-wheel alignment. The correct order for performing these
    13·1 answer
  • Camila wanted to increase the readability of her company newsletter. To do this, she added _____.
    7·2 answers
  • PLS HELP SOON
    15·1 answer
  • 8.6 Code Practice: Question 2
    7·1 answer
  • Kaitlin likes a particular design theme, but she is not sure about every single color for bullets, backgrounds, etc. found in th
    7·1 answer
  • Firewalls are available as a special hardware device or as software. A firewall will block packets of information that are from
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!