Created
December 2, 2014 20:05
-
-
Save Lotuashvili/ad4335e6ade868d690e3 to your computer and use it in GitHub Desktop.
საშუალო არითმეტიკული (Java)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Average { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
double total = 0, grade, average, roundedAverage; | |
int num, count = 0; | |
System.out.print("Sheiyvanet ricxvebis raodenoba: "); | |
num = input.nextInt(); | |
if (num <= 0) { | |
System.out.println("Raodenoba unda iyos 1 an meti"); | |
System.exit(0); | |
} | |
while (count < num) { | |
System.out.print("Sheiyvanet ricxvi #"+(count+1)+": "); | |
grade = input.nextInt(); | |
total = total + grade; | |
count++; | |
} | |
average = total/num; | |
roundedAverage = Math.round( average * 1000.0) / 1000.0; | |
if (average != roundedAverage) System.out.println("Sashualo: " + average + " ~ " + roundedAverage); | |
else System.out.println("Sashualo: " + average); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment