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
marin [14]
4 years ago
7

Write code that prompts for three integers, averages them, and prints the average. Make your code robust against invalid input;

if the user types a non-number, re-prompt with the same prompt message. (You may want to look at the getInt method discussed in Chapter 5. You can call that method in your solution if you like.) Here is an example dialogue: Type an integer: 5 Type an integer: 2 Type an integer: 17 Average: 8.0
Computers and Technology
1 answer:
MArishka [77]4 years ago
6 0

Answer:

The program to this question can be given as:

Program:

import java.util.*;  //import package for user input.

public class Main  //define class-main

{

   public static void main (String ar [])  //define main function

   {

       try  //try block

       {

           int a,b,c,sum=0;  //declare variable

           double average;

           Scanner ob= new Scanner(System.in);  //create Scanner class Object

           System.out.print("Enter first number :");  //message.

           a = ob.nextInt();  //input number.

           System.out.print("Enter second number :");

           b = ob.nextInt();

           System.out.print("Enter third number :");

           c = ob.nextInt();

           //print numbers

           System.out.print("\nFirst number:"+a);

           System.out.print("\nSecondnumber:"+b);

           System.out.print("\nThird number:"+c);

           sum =sum+a+b+c;    //Sum

           average = sum/3;  //Average

           System.out.print("\nAverage:" + average);  //print average

       }  

       catch (Exception e) //catch block.

       {

          System.out.print("Enter number only..!");  //message

       }

   }

}

Output:

Enter first number 5

Enter second number 2

Enter third number 17

First number: 5  

Second number: 2  

Third number: 17  

Average: 8.0

Explanation:

In the above program firstly we import packages for user input. Then we declare the main class. In the main class, we define the main function in the main function we use the exception handling. In the exception handling, we use try and catch block. In the try block firstly we declare variables then create a scanner class object and take input from the user. After user input we add all numbers into the sum variable then we take average in the average variable and print all values. If the user doesn't input a number then we use the catch block in this block it prints a simple message that is "Enter number only..!"

You might be interested in
Peter recently bought a media player and a digital camera he wants to buy memory card for the devices which memory device should
Nastasia [14]
An Sd (secure digital) card. Hope this helps you :)
3 0
3 years ago
Read 2 more answers
Digital art is created by using __?
taurus [48]
A paint or art program on your computer.
7 0
3 years ago
Hard drive access time is measured in
SIZIF [17.4K]

Answer: D) milliseconds

Explanation:

Hard drive access time are measured in milliseconds as, for the personal computer the hard drive access time is about 9 to 15 milliseconds and it basically includes the time taken for the read and write for locate the parts on the disk. As, this is the average time as it depends upon how far the head from desired.

5 0
3 years ago
To complete this quest, answer the following questions in the submission box below. Make x an array going from 0 to 100 by steps
Law Incorporation [45]

Answer:

C++.

Explanation:

#include <iostream.h>

void main(int argc,char* arg[])  {

   // Arrays

   int x[100];

   int y[50];

   int z[50];

////////////////////////////////////////////////////////////////////////////

   int count = 0;

   for (int i = 0; i < 100; i+=2) {

       z[count] = x[i] * y[count];

       count++;

   }

for (int i =0; i < 5; i++) {

   cout<<z[i]<<endl;

}

getche();

}

5 0
3 years ago
While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes
rjkz [21]

While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes did not solve the problem and were not saved. The technician can<u> Issue the reload command without saving the running configuration.</u>

Explanation:

  • The technician does not want to make any mistakes trying to remove all the changes that were done to the running configuration file.
  • The solution is to reboot the router without saving the running configuration. The copy startup-config running-configcommand does not overwrite the running configuration file with the configuration file stored in NVRAM, but rather it just has an additive effect.
  • Configuration change control is a set of processes and approval stages required to change a configuration item's attributes and to re-baseline them.
  • Configuration status accounting is the ability to record and report on the configuration baselines associated with each configuration item at any moment of time.
  • The Manage System Configuration screen allows you to download, save, switch, revert and delete system configuration files.
  • Configuration Control is the activity of managing the product and related documents, throughout the lifecycle of the product.

6 0
3 years ago
Other questions:
  • In an open computer network such as the internet, hipaa requires the use of _____. in a closed system such as a local area netwo
    7·1 answer
  • Have you ever tried to teach a class full of restless, active sixth-graders? I have. I taught sixth-grade students for 12 years.
    15·1 answer
  • When your Windows XP file becomes too large to fit in a single window, which of these components allows you to bring different p
    6·1 answer
  • Computer input is the process of translating physical signals (light, sound, movement) into which of the following?
    8·2 answers
  • Is the following an example of social media viral marketing? Indicate your response by selecting Yes or No.
    7·1 answer
  • Why is an array like a list? How do you identify and find elements in an array? Explain the purpose of a try-catch block and giv
    5·1 answer
  • A security policy is a?
    11·2 answers
  • Assume hosts A and B are each connected to a switch Svia 100-Mbps links. The propagation delay on each link is 25μs. The switch
    15·1 answer
  • How to print something nad input on same line python
    8·1 answer
  • An editing functions used to move selected text or objects to the Clipboard, from which they may be pasted elsewhere in the pres
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!