Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class hotel {
- static float budget = 85;
- static int numFloors = 0;
- static int[] floorsOnRoom = new int[20];
- static int numDecorations = 0;
- public static void main(String[] args) {
- buyRoom(1,2);
- buyRoom(2,2);
- buyRoom(3,2);
- buyRoom(4,2);
- buyRoom(5,2);
- buyRoom(6,2);
- buyRoom(7,2);
- System.out.printf("Week 1 Pre: %.3f\n", budget);
- budget += gefw(1);
- System.out.printf("Week 1: %.3f\n", budget);
- buyRoom(8,2);
- buyDec(8);
- System.out.printf("Week 2 Pre: %.3f\n", budget);
- budget += gefw(1);
- System.out.printf("Week 2: %.3f\n", budget);
- buyRoom(9,2);
- buyRoom(10,2);
- buyRoom(11,2);
- buyRoom(12,2);
- buyRoom(13,2);
- System.out.printf("Week 3 Pre: %.3f\n", budget);
- budget += gefw(1);
- System.out.printf("Week 3: %.3f\n", budget);
- buyRoom(1,1);
- buyRoom(2,1);
- buyRoom(3,1);
- buyRoom(4,1);
- buyRoom(5,1);
- buyRoom(6,1);
- buyRoom(7,1);
- buyRoom(8,1);
- buyRoom(9,1);
- buyRoom(10,1);
- buyRoom(11,1);
- buyRoom(12,1);
- buyRoom(13,1);
- buyDec(4);
- System.out.printf("Week 4 Pre: %.3f\n", budget);
- budget += gefw(1);
- System.out.printf("Week 4: %.3f\n", budget);
- budget += gefw(4);
- System.out.printf("Week 8: %.3f\n", budget);
- }
- static void buyRoom(int floor, int times) {
- for (int x = 0; x < times; x++) {
- if (floorsOnRoom[floor-1] == 0) {
- numFloors++;
- }
- budget -= 6;
- floorsOnRoom[floor-1]++;
- }
- }
- static void buyDec(int num) {
- for (int x = 0;x < num; x++) {
- budget -= 3;
- numDecorations++;
- }
- }
- static float gefw(int times) {
- float totearn = 0;
- for (int i = 0; i < times; i++) {
- float earnings = 0;
- //Add money from rooms
- for (int x = 0; x < numFloors; x++) {
- earnings += floorsOnRoom[x] * (x+1);
- }
- //Add money from decorations
- float dec = numDecorations * 5.0f / 100.0f;
- earnings += earnings * dec;
- //Deduct tax
- float tax = earnings * (numFloors * 5.0f / 100.0f);
- earnings -= tax;
- totearn += earnings;
- }
- return totearn;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement