Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mc_letenky;
- import java.util.Random;
- /**
- *
- * @author Martin
- */
- public class MC_Letenky {
- static final int price = 150;
- static final int maxPeople = 100;
- static final int fixCosts = 8000;
- static final int varCosts = 30;
- static final int comp = 300;
- static final double pFlight = 0.95;
- public static void main(String[] args) {
- Random init = new Random();
- Random init1 = new Random();
- Random r1 = new Random(init.nextLong());
- Random r2 = new Random(init1.nextLong());
- int pocPeople, peopleP, compenz, pride;
- double zisk;
- for (int pocRez = 90; pocRez < 150; pocRez++) {
- zisk = compenz = pocPeople = 0;
- for (int i = 0; i < 1000; i++) {
- for (int j = 0; j < pocRez; j++) {
- if (r1.nextDouble() <= pFlight) {
- pocPeople++;
- }
- }
- }
- peopleP = pocPeople / 1000;
- pride = peopleP;
- if (peopleP > maxPeople) {
- compenz = peopleP - maxPeople;
- pride = 100;
- }
- zisk = pocRez * price - fixCosts - pride * varCosts - compenz * comp;
- System.out.println("Rezervacii: " + pocRez + " Pride: " + peopleP + " ZISK: " + zisk);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement