Computer Science, asked by mrishu682, 8 months ago

write a program to eccept three number, find its average and check whether average is even or odd.​

Answers

Answered by AnshuBhardwaj123
0

for Python

n1=int(input("Enter 1st no.:"))

n2=int(input("Enter 2st no.:"))

n3=int(input("Enter 3st no.:"))

tot=n1+n2+n3

avg=tot/3

print("average of three numbers",n1,n2,n3,"is",avg)

if avg%2==0:

      print("average is even")

else:

      print("average is odd")

hope you like this

Answered by Shivu516
0

This program is in Java.  The average of a number is mostly in decimals and decimals are not even or odd. If it's written 0.3, then you can't say if it is even or odd. As 0.3 can also mean 0.30 and 0.3333333... .  

import java.util.*;

public class AverageCalculator {

   public static void main (String [] args) {

       //Taking input from the user

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the first number: ");

       double num1 = sc.nextDouble();

       System.out.print("Enter the second number: ");

       double num2 = sc.nextDouble();

       System.out.print("Enter the third number: ");

       double num3 = sc.nextDouble();

       //Main part comes here

       double Average = (num1 + num2 + num3) / 3;

       System.out.println("The average of the given numbers is " + Average);

   }

}

Output:

Enter the first number: 30

Enter the second number: 31

Enter the third number: 28

The average of the given numbers is 29.666666666666668

Similar questions