Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

Why is iteration important when creating a behavioral model?

Answered: 1 week ago

Question

2. What, according to Sergey, was strange at this meeting?

Answered: 1 week ago

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago