Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package mc_letenky;
  2.  
  3. import java.util.Random;
  4.  
  5. /**
  6.  *
  7.  * @author Martin
  8.  */
  9. public class MC_Letenky {
  10.  
  11.     static final int price = 150;
  12.     static final int maxPeople = 100;
  13.  
  14.     static final int fixCosts = 8000;
  15.     static final int varCosts = 30;
  16.  
  17.     static final int comp = 300;
  18.     static final double pFlight = 0.95;
  19.  
  20.     public static void main(String[] args) {
  21.         Random init = new Random();
  22.         Random init1 = new Random();
  23.  
  24.         Random r1 = new Random(init.nextLong());
  25.         Random r2 = new Random(init1.nextLong());
  26.  
  27.         int pocPeople, peopleP, compenz, pride;
  28.         double zisk;
  29.  
  30.         for (int pocRez = 90; pocRez < 150; pocRez++) {
  31.             zisk = compenz = pocPeople = 0;
  32.             for (int i = 0; i < 1000; i++) {
  33.                 for (int j = 0; j < pocRez; j++) {
  34.                     if (r1.nextDouble() <= pFlight) {
  35.                         pocPeople++;
  36.                     }
  37.                 }
  38.             }
  39.             peopleP = pocPeople / 1000;
  40.             pride = peopleP;
  41.             if (peopleP > maxPeople) {
  42.                 compenz = peopleP - maxPeople;
  43.                 pride = 100;
  44.             }
  45.  
  46.             zisk = pocRez * price - fixCosts - pride * varCosts - compenz * comp;
  47.             System.out.println("Rezervacii: " + pocRez + " Pride: " + peopleP + " ZISK: " + zisk);
  48.         }
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement