Question: JAVA PROGRAMMING Need help writing Java application. Write a Java application that reads three integers from the user using a Scanner. Then, create functions to

JAVA PROGRAMMING Need help writing Java application.

Write a Java application that reads three integers from the user using a Scanner.

Then, create functions to calculate the sum, product and average of the numbers,

and displays them from main.

(Use each functions' 'return' to return their respective values.) Use the

following sample code as a guide.

Below is a sample code:

import java.util.Scanner;

/**

* Write a Java application that reads three integers from the user using a Scanner.

* Then, create functions to calculate the sum, product and average of the numbers,

and displays them from main.

* (Use each functions' 'return' to return their respective values.) Use the

following sample code as a guide.

*/

public class assignment1_main

{

public static void main(String[] args)

{

int num1, num2, num3;

double sum, product, average;

// Use Scanner class to read the three integer

sum = sum(num1, num2, num3); //The sum method calculates the sum

//Create and call product method to calculate the product

//Create and call average method to calculate the average

System.out.printf("Sum: %f", sum);

// Next print the product and average using similar printf calls.

}//end main

/**

* This method calculates the sum of 3 integers

* @param x the first integer

* @param y the second integer

* @param z the third integer

* @return the sum of the 3 integers

*/

public static double sum(int x, int y, int z)

{

return x + y + z;

}//end sum

}//end class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!