Note that there are some explanatory texts on larger screens.

plurals
  1. POusing a method in java
    primarykey
    data
    text
    <p>I wrote below code to satisfy program requirement as follows: </p> <blockquote> <p>Average of Three Write a program that reads three whole numbers and displays the average of the three numbers.</p> <p>Input Notes: Three whole numbers (non-negative integers) are entered at the console. </p> <p>Output Notes (Prompts and Labels): The program prompts for the three integers with these strings: "Enter the first integer.", "Enter the second integer.", "Enter the third integer.". The program then prints         The average of NUMBER1,  NUMBER2,  and NUMBER3  = AVG   where NUMBER1  is the first integer value entered and NUMBER2  and NUMBER3  the subsequent integers, and AVG  is the computed average value. </p> <p>SPECIFICATION OF NAMES: Your application class should be called Average3:</p> </blockquote> <p>My source code:</p> <pre><code>import java.util.Scanner; public class Average3 { /** * @param args */ public static void main(String[] args) { int AVG, NUMBER1, NUMBER2, NUMBER3; System.out.println("Enter the first integer."); Scanner keyboard = new Scanner(System.in); NUMBER1 = keyboard.nextInt(); System.out.println("Enter the second integer."); NUMBER2 = keyboard.nextInt(); System.out.println("Enter the third integer."); NUMBER3 = keyboard.nextInt(); AVG = (NUMBER1 + NUMBER2 + NUMBER3) / 3; System.out.println("The average of NUMBER1, NUMBER2, and NUMBER3 = " + AVG); } } </code></pre> <p>My program compiles fine but I know I could have implemented and invoked an object with an associated method but am struggling where to start I understand the methods and objects conceptually but not as far as writing code. Anyone have any suggestions? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload