Get more lessons like this at http://www.MathTutorDVD.com
Learn how to program in java with our online tutorial. We will cover variables, loops, if else branching, arrays, strings, objects, classes, object oriented programming, conditional statements, and more.
Here we practice passing a parameter to a method, performing a calculation, and returning the result.
following the steps. yet to grab the copy
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in);
System.out.println("Separately input two integers from 1 to 100.n");
System.out.println("enter first grade; ");
double gradeA = myObj.nextDouble();
System.out.println("enter second grade; ");
double gradeB = myObj.nextDouble();
System.out.println("enter third grade; ");
double gradeC = myObj.nextDouble();
System.out.println("Average grade is " + averageGrades(gradeA, gradeB, gradeC));
}
public static double averageGrades (double a, double b, double c) {
return ((double)(a + b + c) / 3);
}
}
I really love your videos
I am doing with for loop but I have a problem with the method. how can I send the values for grade1, grade2, grade3, to the method?