Computer Science, asked by rosalinrawat50, 5 months ago

write a program to input 3 number and find the sum and average​

Answers

Answered by jeromeseejo73
1

Answer:

I am using Java.

import java. util. Scanner;

public class number

{

public static void main(String[] args)

{

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();

double sum= num1+num2+num3;

double avg=sum/3;

System.out.println("The sum of the 3 numbers is: "+sum) ;

System.out.println("The average of the 3 numbers is: "+avg) ;

}

}

Answered by anindyaadhikari13
1

Question:-

  • Write a program to input 3 numbers and find their sum and average.

Program:-

import java.util.*;

class Sum_Average

{

public static void main()

{

double a b, c, s=0, av=0;

Scanner sc = new Scanner(System.in);

System.out.println("Enter 3 numbers..");

a=sc.nextDouble();

b=sc.nextDouble();

c=sc.nextDouble();

s=a+b+c;

av=s/3.0;

System.out.println("Sum is: "+s);

System.out.println("Average is: "+av);

}

}

Similar questions