Finding the average of two number using classes and methods
        Posted  
        
            by Have alook
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Have alook
        
        
        
        Published on 2010-03-23T18:09:06Z
        Indexed on 
            2010/03/23
            18:13 UTC
        
        
        Read the original article
        Hit count: 330
        
I want to use methods inside class.
Q: find the average of two number using classes and methods.
import java.util.*;
class aaa {
    int a,b,sum,avrg;
    void average() {
        System.out.println("The average is ="+avrg);
        avrg=(sum/2);
    }
}
class ave {
    public static void main(String args[]){
        aaa n=new aaa();
        Scanner m=new Scanner(System.in);
        System.out.println("write two number");
        n.a=m.nextInt();
        n.b=m.nextInt();
        n.average();
    }
}
© Stack Overflow or respective owner