Finding the average of two number using classes and methods
- by Have alook
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();
}
}