Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java code needed ription Three Numbers (Required Exercise) In this exercise we'll be using a slightly different combination of things we've worked on before, starting
java code needed
ription Three Numbers (Required Exercise) In this exercise we'll be using a slightly different combination of things we've worked on before, starting from scratch again. No individual element here is new, so read the instructions carefully and break the task down into steps. In the skeleton you are given a class ThreeNumbers which starts with an array called num, and little else. Below the indicated comment you need to do the following (you may want to think about the order): Create a standard main method. In the main method you need to: o Create a scanner object to be used to read things in o Print a prompt to "Enter the first number: ", without a new line after it. Read an int in from the user and store it as the first element of num. o Print a prompt to "Enter the second number: ", without a new line after it. Read an int in from the user and store it as the second element of num. Print a prompt to "Enter the third number: ", without a new line after it. o Read an int in from the user and store it as the third element of num. Print "The sum of the three numbers is .", with a new line after it, where is replaced by the actual sum of the elements of num. o Print "The average of the three numbers is .", with a new line after it, where is replaced by the actual average (rounded down, so you can use integer division) of the the elements of num. Remember that computers aren't clever, so note the formatting and punctuation, especially in the feedback of the tests. Note also that part of the task is to use the array num. Although you can print out the correct things without it, you cannot pass the task. Three Numbers (Required Exercise) ThreeNumbers.java 1 import java.util.Scanner; 2 3 /* 4 *@author Raymond Lister 5 * @version March 22, 2015 6 */ 7 class ThreeNumbers 8 { 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 } 28 static int [] num = 0, 0, 0); // DO NOT CHANGE ANYTHING ABOVE THIS COMMENT LINE //Create a main method. //Create a Scanner //Prompt the user as per the description and read in an int. //Prompt the user as per the description and read in another int. //Prompt the user as per the description and read in the third int. 7/Calculate the sum. //Calculate the average. //Print out the messages about the sum and average. //Don't forget to put a closing brace at the end of the main method.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Java code import javautilScanner public class ThreeNumbers public stat...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started