Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

    • Create a Scanner object to be used to read things in

    • 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.

    • 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.

    • 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.

    • 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.

import java.util.Scanner;

/*
* @author Raymond Lister
* @version March 22, 2015
*/
class ThreeNumbers
{
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.

//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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Programming questions

Question

What are the responsibilities of the position?

Answered: 1 week ago

Question

Use translations to graph f. f(x) = x-/2 +1

Answered: 1 week ago

Question

Is the timing right to launch your venture?

Answered: 1 week ago