Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package priemer;
- import java.util.Scanner;
- public class Priemer {
- public static void main(String[] args){
- System.out.println("Program na vypocet vazeneho priemeru");
- System.out.println("Zadaj pocet znamok:");
- Scanner scan = new Scanner(System.in, "UTF-8");
- int pocet = Integer.parseInt(scan.nextLine());
- float[] znamky = new float[pocet];
- int[] kredity = new int[pocet];
- for (int i=0; i<pocet; i++){
- System.out.printf("Zadaj %d znamku:\n", i+1);
- znamky[i]=Float.parseFloat(scan.nextLine());
- System.out.printf("Zadaj pocet kreditov:\n");
- kredity[i]=Integer.parseInt(scan.nextLine());
- }
- scan.close();
- float sucetZnamok = 0F;
- int sucetKreditov = 0;
- for (int i=0; i<pocet; i++){
- sucetZnamok += znamky[i]*kredity[i];
- sucetKreditov += kredity[i];
- }
- System.out.println(sucetZnamok/sucetKreditov);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement