Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Talar;
- import java.util.Random;
- public class Main {
- public static void main(String[] args) {
- Random rand = new Random();
- int max = Integer.MIN_VALUE;
- int min = Integer.MAX_VALUE;
- int r1 = 0; int r2 = 0;
- int ilosc = 0;
- long iloczyn = 1;
- int suma = 0;
- do{
- r1 = rand.nextInt(150)-50;
- ilosc++;
- if(max<r1) { max = r1; }
- else if(min>r1) { min = r1; }
- if(r1>0 && r1%2==0){
- iloczyn *= r1;
- }
- //System.out.println(r1);
- }
- while(r1!=0);
- System.out.print("max: " +max + ", min:" + min + "\nIloczyn liczb parzystych dodatnich: " + iloczyn + "\n");
- for(int i = 0; i<ilosc; i++){
- r2 = rand.nextInt(25)-25;
- if(r2!=0){
- if(i%2==0){
- suma += r2;
- }
- }
- //System.out.println(r2);
- }
- System.out.println("Suma: " + suma);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement