// 10/2/2017
// return value
// A method should be able to give back an answer based on its
// calculations, e.g. sqrt, pow, abs, average

import java.util.Scanner;

/** This class illustrates returning a value from a method
  */
public class ReturnValues2 {
  /** main method calls calculateSum
    *  
    */
  public static void main(String[] args)   {
     double num1=5.1, num2=26.7;
     System.out.println("sum is " + calculateSum(num1, num2));
     double s;
     s=calculateSum(95.4, num1);
     System.out.println("In main, value of s is: " + s);
  }
  /** 
   * method calculateSum accepts 2 double values and adds them.
   * @param val   first value to be added.
   * @param val2  second value to be added.
   * @return returns the sum of the 2 numbers.
   */
  // data type of the value to return goes before name of method
  public static double calculateSum(double val, double val2)  {
     // sum is called a local variable
     // double sum=val+val2;
     // return 5; you can return a literl
     // you can also return the value of an expression
     return val+val2;
  }  
} 