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
Choose 2 statements that correctly describe the time complexity of data structures with N data.
Rashid [163]

The  2 statements that correctly describe the time complexity of data structures with N data are:

  • The average time complexity of data structures with N data is O(N).
  • The average time complexity of inserting data into a heap is O(logN)

<h3>What is Time Complexity in the above case/</h3>

This is known to be the amount of times a specific instruction set is executed instead of the total time is taken.

Note that The  2 statements that correctly describe the time complexity of data structures with N data are:

  • The average time complexity of data structures with N data is O(N).
  • The average time complexity of inserting data into a heap is O(logN)

Learn more about data structure from

brainly.com/question/13147796

#SPJ1

8 0
2 years ago
List two panels that allow you to adjust the properties of your titles.
antiseptic1488 [7]

Answer:

1. The tools panel

2. The actions panel

Explanation:

The tools panel contains properties that allow for text and object creation. The actions panel contains properties that allow for the alignment and distribution of titles.

Under the tools panel, we can find properties like; line, arc, an arrow for selection, different shapes like rectangle and the clipped corner, vertical type, vertical area type, vertical path type, etc. Under the actions panel, properties like; align, center, and distribute can be found.

8 0
3 years ago
Suppose a linked list of 20 nodes. The middle node has a data –250. Write the pseudocode to replace the middle node of the linke
dexar [7]

Answer:

The middle node has a data –250. ... Write The Pseudocode To Replace The Middle Node Of The Linked List With ... Assume That The List's Head Pointer Is Called Head_ptr And The Data For The New Node Is Called Entry ... Assume that the list's head pointer is called head_ptr and the data for the new node is called entry ...

Explanation:

4 0
4 years ago
Read 2 more answers
Write a Comparator that compares String objects by the number of words they contain. Consider any nonwhitespace string of charac
Readme [11.4K]

Answer:

import java.util.Scanner;

public class num12 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter the first String");

       String word1 = in.nextLine();

       System.out.println("Enter the second String");

       String word2 = in.nextLine();

       System.out.println("Enter the third String");

       String word3 = in.nextLine();

       //Remove all white spaces

        String cword1 = word1.replace(" ","");

       String cword2 = word2.replace(" ","");

       String cword3 = word3.replace(" ","");

       //Comparing the string by their lengths

       if(cword1.length()>cword2.length()&&cword1.length()>cword3.length()){

           System.out.println(word1+" Is the longest");

       }

       else if(cword2.length()>cword1.length()&&cword2.length()>cword3.length()){

           System.out.println(word2+" Is the longest");

       }

       else{

           System.out.println(cword3+" Is the longest");

       }

   }

}

Explanation:

Using Java Programming Language

Use the Scanner Class to obtain the String values from the user

Save them in different variables

Use the replace() method in java to remove white space from any of the string entered

Using if and else statements compare the lengths of the strings (word.length()) returns the length of the word.

Print out the word that is longest

NOTE I have compared three Strings, comparing two would have been more straigth forward

8 0
4 years ago
The connectors on the computer allow you to plug in devices such as keyboards and printers. what are these called?
madam [21]
USB port. That allows you to plug in devices.
8 0
4 years ago
Other questions:
  • _____ learners prefer to interact with others on group projects.
    8·1 answer
  • Explain why computer users should use the cloud?
    14·1 answer
  • If you witness physical bullying and want to help, what should you consider first?
    5·1 answer
  • Write another function to convert a value to its word equivalent leveraging the following tuple - o Number = (‘One’, ‘Two’, … ‘N
    10·1 answer
  • Why was Unicode invented?
    11·1 answer
  • How long would it take a 8 bit computer to calculate π to the thousandth place?
    8·1 answer
  • A user who enters americanbank.net into a web browser instead of the correct americanbank and is then taken to a fake look-alike
    11·2 answers
  • What accesses organizational databases that track similar issues or questions and automatically generate the details to the repr
    14·1 answer
  • Trees 1. 2. 3. 4. 5.​
    6·1 answer
  • Anyone here good with Alice? I need help ASAP
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!