Programming Examples

Java program to input 5 real numbers and find their average If the average is greater than 50 print good otherwise print bad


Write a program to input 5 real numbers(floating point) and find their average. If the average is greater than 50 print good, otherwise print bad.

Solution

import java.util.*;
class GoodBad
{
	public static void main(String arr[])
	{
		float a,b,c,d,e,av;
		Scanner sc=new Scanner(System.in);
		System.out.println(“Enter 5 real numbers:”);
		a=sc.nextFloat();
		b=sc.nextFloat();
		c=sc.nextFloat();
		d=sc.nextFloat();
		e=sc.nextFloat();
		av=(a+b+c+d+e)/5;
		System.out.println(“Average=”+av);
		if(av>50)
			System.out.println(“Good”);
		else
			System.out.println(“Bad”);
	}
}
Output

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz