Question
// Hotel Suites occupancy // This program calculates the occupancy rate for a hotel's suites. // These are located on floors 10-16. There is no
// Hotel Suites occupancy // This program calculates the occupancy rate for a hotel's suites. // These are located on floors 10-16. There is no 13th floor. import java.util.Scanner; import java.text.*; public class hotelOccupancy { public void calcRate() { final int SUITES_PER_FLOOR = 20, // Number of suites per floor MIN_FLOOR = 10, // Lowest floor of suite units MAX_FLOOR = 16, // Highest floor of suite units TOTAL_SUITES = (MAX_FLOOR - MIN_FLOOR) * SUITES_PER_FLOOR; Scanner scan = new Scanner(System.in); DecimalFormat fmt = new DecimalFormat(); int occupied, // Number of occupied suites on the floor totalOccupied = 0; // Total number of occupied suites double occupancyRate; // % of the suites that are occupied // Get and validate occupancy information for each floor System.out.println("Enter the number of occupied suites on each of the following floors. "); for (int floor = MIN_FLOOR; floor <= MAX_FLOOR; floor++) { if (floor == 13) continue; // Skip thirteenth floor System.out.println(" Floor " + floor+ ": "); occupied=scan.nextInt(); while (occupied < 0 && occupied > SUITES_PER_FLOOR) { System.out.println(" The number of occupied suites must be between 0 and " + SUITES_PER_FLOOR ); System.out.println(" Re-enter the number of occupied suites on floor " + floor + ": "); occupied = scan.nextInt(); } // Add occupied suites on this floor to the total totalOccupied += occupied; } // Compute occupancy rate in % form occupancyRate = 100* totalOccupied / TOTAL_SUITES; // Display results System.out.println(" The hotel has a total of " + TOTAL_SUITES + " suites. "); System.out.println(totalOccupied+ " are currently occupied. "); System.out.println("This is an occupancy rate of " + fmt.format(occupancyRate)+ "% "); } }
Suppose you want to perform basic path testing and D-U path testing for the Java program given that calculates the Hotel Suites occupancy. These are located on floors 10-16. There is no 13th floor. a) Draw the control flow graph and design test cases to perform basic path testing Submit: clearly labeled control flow graph and test cases b) Implement Junit code to run test cases for each path. Do you get the desired output? Use eclEmma and report the code coverage of your tests. Submit: your Junit test program and a screenshot of code coverage using eclEmma. c) Now design test cases for D-U path testing for variables occupancyRate and totalOccupied. Submit: clearly labeled D-U graph and test cases for both variables above. d) Identify bugs in the program using test cases b and c above and fix them Submit: correct program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started