lab & assignment

This commit is contained in:
2024-10-23 15:11:20 +03:00
parent 8928b8471a
commit b1f377bfec
9 changed files with 126 additions and 3 deletions

24
labs/lab2/Average.java Normal file
View File

@ -0,0 +1,24 @@
// *******************************************************************
// Average.java
//
// Read three integers from the user and print their average
// *******************************************************************
import java.util.Scanner;
public class Average
{
public static void main(String[] args)
{
int val1, val2, val3;
double average;
Scanner scan = new Scanner(System.in) ;
// get three values from user
System.out.println("Please enter three integers and " +
"I will compute their average");
val1 = scan.nextInt();
val2 = scan.nextInt();
val3 = scan.nextInt();
average = (val1 + val2 + val3)/3;
System.out.println(average);
}
}