Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Talar;
- import java.util.Scanner;
- import java.util.Random;
- public class Main {
- public static void main(String[] args) {
- //Zad1
- /*Random rand = new Random();
- int dochod[] = new int[12];
- int suma = 0;
- int srednia = 0;
- for(int i=0; i<dochod.length; i++){
- int r = rand.nextInt(4000)+800;
- dochod[i] = r;
- System.out.println(dochod[i]);
- suma += dochod[i];
- }
- srednia = suma/dochod.length;
- System.out.println("Suma: " + suma + ", średnia: " + srednia);
- */
- //Zad2
- /*Scanner inp = new Scanner(System.in);
- Scanner inp2 = new Scanner(System.in);
- System.out.print("Ile czasów: "); int ile = inp.nextInt();
- double[] czasy = new double[ile];
- double max = Double.MIN_VALUE;
- double min = Double.MAX_VALUE;
- double suma = 0; double srednia = 0;
- for(int i=0; i<czasy.length; i++){
- System.out.print("Czas " + (i+1) + ": "); czasy[i] = inp2.nextDouble();
- if(czasy[i]<0) { i--; }
- }
- for(int j=0; j<czasy.length; j++){
- System.out.println(czasy[j]);
- if(czasy[j] > 0){
- suma += czasy[j];
- if(max<czasy[j]) max = czasy[j];
- if(min>czasy[j]) min = czasy[j];
- }
- }
- srednia = suma/czasy.length;
- System.out.println("Srednia: " + srednia + ", max: " + max + ", min: " + min);*/
- //Zad5
- /*Scanner inp = new Scanner(System.in);
- int dwa = 0; int trzy = 0; int cztery = 0; int piec = 0;
- int[] oceny = new int[5]; boolean x = true;
- for(int i = 0; i < oceny.length; i++){
- System.out.print("Wprowadź ocene: "); oceny[i] = inp.nextInt();
- if(oceny[i] < 2 || oceny[i] > 5) { i--; x = false;}
- else { x = true; }
- if(x==true) {
- if (oceny[i] == 2) dwa++;
- if (oceny[i] == 3) trzy++;
- if (oceny[i] == 4) cztery++;
- if (oceny[i] == 5) piec++;
- }
- }
- System.out.println("Dwa: " + dwa);
- System.out.println("Trzy: " + trzy);
- System.out.println("Cztery: " + cztery);
- System.out.println("Pięć: " + piec);
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement