Thursday, August 13, 2020

Print the average of three numbers given by user by creating a class named 'Average' having a method to calculate and print the average.

 class  Average

{

int a=5,b=4,c=3;

float avg;

void calaverage()

{

avg=(a+b+c)/3;

}

void printavg()

{

System.out.println("Average of three varibales"+avg);

}

public static void main(String[] args) 

{

    Average a1=new Average();

     a1.calaverage();

a1.printavg();

}

}


No comments:

Post a Comment