import java.util.Random;
class bananas
{
public static void main(String args[])
{
int no1,no2,no3,no4,sum,avg,min,max,a,b,c,d;
Random rn = new Random();
no1 = rn.nextInt(99)+1;
no2 = rn.nextInt(99)+1;
no3 = rn.nextInt(99)+1;
no4 = rn.nextInt(99)+1;
System.out.println("Random numbers are as follow: " +"\n"+ no1 +"\n"+ no2 +"\n"+ no3 +"\n"+ no4);
sum = no1+no2+no3+no4;
avg = (no1+no2+no3+no4)/4;
min = Math.min(a=(Math.min(no1,no2)),b=(Math.min(no3,no4)));
max = Math.max(c=(Math.min(no1,no2)),d=(Math.max(no3,no4)));
System.out.println("Sum:"+sum+"\nAverage:"+avg+"\nSmallerst number:"+min+"\nLargest number:"+max);
}
}
Quick Links to Application questions (with solutions)!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment