Search This Blog

save java programs with".java" extension

examples :

helloworld.java
sample.java
match.java
send-mail.java

quick links

total and average in java

/* total and average */
class tatavg
{
public static void main(String args[])
{
int m1=50,m2=50,m3=70;
int tot=m1+m2+m3;
float avg=tot/3;
System.out.println("m1   :"+m1);
System.out.println("m2   :"+m2);
System.out.println("m3   :"+m3);
System.out.println("\nsum  :"+tot);
System.out.println("\naverage (total/3)  :"+avg+"\n\n");
}
}

output :
m1  :50
m2  :50
m3  :70

sum  :170

average (total/3)  :56.0