Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/********************************************************** * Program Name : Pra

ID: 3761121 • Letter: #

Question

 /**********************************************************  * Program Name   : Practice Coding - Creating Methods  * Author         :  * Date           : April 01, 2010  * Course/Section : CSC111 - 01  * Program Description: This program will act as the driver  *   for the calculate GPA lab  *  * Methods:  * -------  * Main - manages a student GPA  *  **********************************************************/   public class CreatingMethods {     static Library myLib;     /**********************************************************     * Method Name    : Main     * Author         : Professor Scheemaker     * Date           : April 01, 2010     * Course/Section : CSC111 - 01     * Program Description:     *     * BEGIN Creating Methods     *     Input 3 integers     *     Clear screen     *     Call a method to return the avg of the three integers     *     Call a method to disploay the avg to 2 decimal places     * END Creating Methods     **********************************************************/     public static void main (String [] args)    {       //local constants        //local variables            myLib = new Library(); //instantiate        /********************   Start main method  *****************/        //input three integers        //call method to find average of three integers        //call method to display the average to 2 decimal places     }    /**********************************************************     * Method Name    : calcAvg     * Author         :     * Date           : April 01, 2010     * Course/Section : CSC111 - 01     * Program Description:     *     * BEGIN Calculate Average(num1, num2, num3)     *     calculate average of 3 integer parameters     *     return the average     * END Creating Methods     **********************************************************/     public     {            //local constants             //local variables              /******************************************************/           }//end calcAvg      /**********************************************************     * Method Name    : dispAvg     * Author         :     * Date           : April 01, 2010     * Course/Section : CSC111 - 01     * Program Description:     *     * BEGIN Display the average(average)     *     format the average to 2 decimal places     *     display average on the screen     * END Creating Methods     **********************************************************/     public     {            //local constants             //local variables              /******************************************************/           }//end dispAvg  } //end Creating Methods  

Explanation / Answer

import java.util.Scanner;

public class CreatingMethods

{

   static Library myLib;

   /**********************************************************

* Method Name : Main

* Author : Professor Scheemaker

* Date : April 01, 2010

* Course/Section : CSC111 - 01

* Program Description:

*

* BEGIN Creating Methods

* Input 3 integers

* Clear screen

* Call a method to return the avg of the three integers

* Call a method to disploay the avg to 2 decimal places

* END Creating Methods

**********************************************************/

   public static void main (String [] args)

   {

//local constants

//local variables

Scanner sc = new Scanner(System.in);

myLib = new Library(); //instantiate

/******************** Start main method *****************/

//input three integers

System.out.print("Enter integer 1: ");

int num1 = sc.nextInt();

System.out.print("Enter integer 2: ");

int num2 = sc.nextInt();

System.out.print("Enter integer 3: ");

int num3 = sc.nextInt();

//call method to find average of three integers

double average = calculateAverage(num1, num2, num3);

//call method to display the average to 2 decimal places

  

displayAverage(average);

   }

   /**********************************************************

* Method Name : calcAvg

* Author :

* Date : April 01, 2010

* Course/Section : CSC111 - 01

* Program Description:

*

* BEGIN Calculate Average(num1, num2, num3)

* calculate average of 3 integer parameters

* return the average

* END Creating Methods

**********************************************************/

public static double calculateAverage(int num1, int num2, int num3)

{

   //local constants

   //local variables

   return (num1+num2+num3)/3.0;

}//end calcAvg

   /**********************************************************

* Method Name : dispAvg

* Author :

* Date : April 01, 2010

* Course/Section : CSC111 - 01

* Program Description:

*

* BEGIN Display the average(average)

* format the average to 2 decimal places

* display average on the screen

* END Creating Methods

* @return

**********************************************************/

public static void displayAverage(double average)

{

   //local constants

   //local variables

          

   System.out.printf("Average is: %.2f ", average);

}//end dispAvg

} //end Creating Methods