write a program in java to input a number and display the average of the digits in the number
Answers
Answer:
Java Program
import static java.lang.Float.sum;
import java.util.Scanner;
public class Average {
public static void main(String[] args)
{
int n, count = 1;
float xF, averageF, sumF = 0;
Scanner sc = new Scanner(System.in);
Explanation:
if you like my answer then follow me
Answer:
import java.util.Scanner;
public class Exercise12 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int num1 = in.nextInt();
System.out.print("Input second number: ");
int num2 = in.nextInt();
System.out.print("Input third number: ");
int num3 = in.nextInt();
System.out.print("Input fourth number: ");
int num4 = in.nextInt();
System.out.print("Enter fifth number: ");
int num5 = in.nextInt();
System.out.println("Average of five numbers is: " +
(num1 + num2 + num3 + num4 + num5) / 5);
}
}
Explanation:
Package name is your wish with out writing any package name it will compile
If you like my program follow me