Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1. class hotel {
  2.   static float budget = 85;
  3.   static int numFloors = 0;
  4.   static int[] floorsOnRoom = new int[20];
  5.   static int numDecorations = 0;
  6.  
  7.   public static void main(String[] args) {
  8.  
  9.     buyRoom(1,2);
  10.     buyRoom(2,2);
  11.     buyRoom(3,2);
  12.     buyRoom(4,2);
  13.     buyRoom(5,2);
  14.     buyRoom(6,2);
  15.     buyRoom(7,2);
  16.  
  17.     System.out.printf("Week 1 Pre: %.3f\n", budget);
  18.     budget += gefw(1);
  19.     System.out.printf("Week 1: %.3f\n", budget);
  20.  
  21.     buyRoom(8,2);
  22.     buyDec(8);
  23.  
  24.     System.out.printf("Week 2 Pre: %.3f\n", budget);
  25.     budget += gefw(1);
  26.     System.out.printf("Week 2: %.3f\n", budget);
  27.  
  28.     buyRoom(9,2);
  29.     buyRoom(10,2);
  30.     buyRoom(11,2);
  31.     buyRoom(12,2);
  32.     buyRoom(13,2);
  33.  
  34.     System.out.printf("Week 3 Pre: %.3f\n", budget);
  35.     budget += gefw(1);
  36.     System.out.printf("Week 3: %.3f\n", budget);
  37.  
  38.     buyRoom(1,1);
  39.     buyRoom(2,1);
  40.     buyRoom(3,1);
  41.     buyRoom(4,1);
  42.     buyRoom(5,1);
  43.     buyRoom(6,1);
  44.     buyRoom(7,1);
  45.     buyRoom(8,1);
  46.     buyRoom(9,1);
  47.     buyRoom(10,1);
  48.     buyRoom(11,1);
  49.     buyRoom(12,1);
  50.     buyRoom(13,1);
  51.     buyDec(4);
  52.  
  53.     System.out.printf("Week 4 Pre: %.3f\n", budget);
  54.     budget += gefw(1);
  55.     System.out.printf("Week 4: %.3f\n", budget);
  56.  
  57.  
  58.  
  59.     budget += gefw(4);
  60.     System.out.printf("Week 8: %.3f\n", budget);
  61.   }
  62.  
  63.   static void buyRoom(int floor, int times) {
  64.     for (int x = 0; x < times; x++) {
  65.       if (floorsOnRoom[floor-1] == 0) {
  66.         numFloors++;
  67.       }
  68.       budget -= 6;
  69.       floorsOnRoom[floor-1]++;
  70.     }
  71.   }
  72.  
  73.   static void buyDec(int num) {
  74.     for (int x = 0;x < num; x++) {
  75.       budget -= 3;
  76.       numDecorations++;
  77.     }
  78.   }
  79.  
  80.   static float gefw(int times) {
  81.     float totearn = 0;
  82.     for (int i = 0; i < times; i++) {
  83.       float earnings = 0;
  84.  
  85.       //Add money from rooms
  86.       for (int x = 0; x < numFloors; x++) {
  87.         earnings += floorsOnRoom[x] * (x+1);
  88.       }
  89.  
  90.       //Add money from decorations
  91.       float dec = numDecorations * 5.0f / 100.0f;
  92.       earnings += earnings * dec;
  93.       //Deduct tax
  94.       float tax = earnings * (numFloors * 5.0f / 100.0f);
  95.       earnings -= tax;
  96.       totearn += earnings;
  97.     }
  98.     return totearn;
  99.   }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement