Menu

Java Programming Need Help Writing Java Application Write Java Application Reads Three Int Q43859005

JAVA PROGRAMMING
Need help writing Java application.

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

Then, create functions to calculate the sum, product and averageof the numbers,

and displays them from main.

(Use each functions’ ‘return’ to return their respectivevalues.) 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 theuser using a Scanner.

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

and displays them from main.

* (Use each functions’ ‘return’ to return their respectivevalues.) 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 thesum

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

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

Expert Answer


Answer to JAVA PROGRAMMING Need help writing Java application. Write a Java application that reads three integers from the user u…

OR