Java-Ağırlıklı ortalama notu hesaplama

Konu sahibi son olarak 3306 gün önce görüldü
Ağırlıkları yüzde olarak Y1, Y2, Y3 ve Y4 olan sınavlardan sırasıyla N1, N2, N3 ve N4 notlarını alan öğrencinin ağırlıklı not ortalamasını bulan bir program yazınız.


Kod:
package cxc;

import java.util.Scanner;

public class xzx {

        public static void main(String[] args) {
                // TODO Auto-generated method stub
                // bu kod VOLKAN KURAL tarafından yapılmıştır
                int n1;
                int y1;
                int n2;
                int y2;
                int n3;
                int y3;
                int n4;
                int y4;
                int o1;
                int o2;
                int o3;
                int o4;
                int sonuç;
                Scanner klavye = new Scanner (System.in);       
                System.out.print("1. notu girin: ") ;
                n1 = klavye.nextInt ();
                System.out.print("1. notun ort ağırlığını girin: ") ;
                y1 = klavye.nextInt ();
                System.out.print("2. notu girin: ") ;
                n2 = klavye.nextInt ();
                System.out.print("2. notun ort ağırlığını girin: ") ;
                y2 = klavye.nextInt ();
                System.out.print("3. notu girin: ") ;
                n3 = klavye.nextInt ();
                System.out.print("3. notun ort ağırlığını girin: ") ;
                y3 = klavye.nextInt ();
                System.out.print("4. notu girin: ") ;
                n4 = klavye.nextInt ();
                System.out.print("4. notun ort ağırlığını girin: ") ;
                y4 = klavye.nextInt ();
                o1=n1*y1/100;
                o2=n2*y2/100;
                o3=n3*y3/100;
                o4=n4*y4/100;
                sonuç=o1+o2+o3+o4;
                System.out.print("ağırlıklı not ortalaması: "+sonuç);
        }

}
 
Geri