The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Software QA/Testing:
Suppose you want to perform basic 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.
Draw the control flow graph to perform basic path testing.
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.n");
  for (int floor = MIN_FLOOR; floor <= MAX_FLOOR; floor++)
  {
     if (floor == 13)
         continue;       // Skip thirteenth floor
    Â
     System.out.println("nFloor " + floor+ ": ");
     occupied=scan.nextInt();                            Â
     while (occupied < 0 && occupied > SUITES_PER_FLOOR)
     {
        System.out.println("nThe number of occupied suites must be between 0 and " + SUITES_PER_FLOOR );
        System.out.println("n 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("nnThe hotel has a total of " + TOTAL_SUITES + " suites.n");
  System.out.println(totalOccupied+ " are currently occupied.n");
  System.out.println("This is an occupancy rate of " + fmt.format(occupancyRate)+ "% n");  Â
}
}
-----------