Практикум по программированию. Основы. Массивы. Процент полученных оценок

From AsIsWiki
Revision as of 19:59, 4 April 2015 by Alex (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Массивы


Contents

Java

import java.util.Scanner;
import java.lang.Math;

public class Task20 {

    private static final int n = 25;

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println(" Статистическая обработка результатов контрольной работы ");
        System.out.println("---------------------------------------------------------");
	
	int a[] = new int[n];

	System.out.print(" Оценки:");

	for (int i = 0; i < n; i++) {
	    a[i] = (int) (2 + 4 * Math.random());
	    System.out.print(" " + a[i]);
	}

	int s = 0, pt = 0, ch = 0, tr = 0, dv = 0;

	for (int i = 0; i < n; i++) {

	    s += a[i];

	    if (a[i] == 2) {
		dv++;
	    }
	    if (a[i] == 3) {
		tr++;
	    }
	    if (a[i] == 4) {
		ch++;
	    }
	    if (a[i] == 5) {
		pt++;
	    }
	}

        System.out.println("\n---------------------------------------------------------");
	System.out.printf(" Пятерок:  %5.2f%%\n", (double) pt / s * 100);
	System.out.printf(" Четверок: %5.2f%%\n", (double) ch / s * 100);
	System.out.printf(" Троек:    %5.2f%%\n", (double) tr / s * 100);
	System.out.printf(" Двоек:    %5.2f%%\n", (double) dv / s * 100);
    }
}


C++



Pascal




Массивы

Personal tools
Namespaces

Variants
Actions
Navigation
Tools