2. Write a java program to:
(value4, value5, value6 and average-value should be replaced with real values stored in variables var4, var5, var6 and avg)
This is meant to be written in Java 14.0
Below is the code for given question. The question is not asking for Bitwise right shift of var4, var5 and var6, it asks for only normal shift which will have no effect on average value.
import java.util.Scanner;
public class Code {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
double var4 = scan.nextDouble();
double var5 = scan.nextDouble();
double var6 = scan.nextDouble();
scan.close();
System.out.print("the average of numbers var4, var5 and var6 is" + avgg(var4, var5, var6) );
}
public static double avgg(double value4, double value5, double value6)
{
return (value4 + value5 + value6) / 3;
}
}
Get Answers For Free
Most questions answered within 1 hours.