Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class L10Methods{
- public static void main(String[] args){
- average(7, 23);
- System.out.println( f(1.0) );
- double fOf2 = f( 2.0 );
- System.out.println( fOf2 );
- for(double i = 1.0; i <= 10.0; i++) System.out.println( f(i) );
- }
- //a method that returns the output of a function f
- // x -> f -> f(x) aka y
- // the function f is 3x + 5
- public static double f( double x ){
- double fx = 3 * x + 5;
- return fx;
- }
- //a method that calculates the average of two nums
- //method takes in two values and prints the average
- public static void average(double num1, double num2){
- System.out.println( ( num1 + num2 ) / 2 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement