It works just fine, but is there any other way to write this shorter?
Nurses are only available to intensive care patients (room I) and TV's and telephones are only available to non intensive care patients (room D or room P). Also, X_COST
has a value of 0.
if (room.equals("I")) { // if (room.equals("I"))
roomCost = 395 * (double)days;
//System.out.println(roomCost);
TVCost = X_COST;
//System.out.println(TVCost);
phoneCost = X_COST;
//System.out.println(phoneCost);
if (nurse.equals("X"))
nurseCost = X_COST;
//System.out.println(nurseCost);
else if (room.equals("N"))
nurseCost = 250 * (double)days;
//System.out.println(nurseCost);
else
nurseCost = 275 * (double)days;
//System.out.println(nurseCost);
} // if (room.equals("I"))
else if (room.equals("P")) { // else if (room.equals("P"))
roomCost = 350 * (double)days;
//System.out.println(roomCost);
nurseCost = X_COST;
//System.out.println(nurseCost);
if (TV.equals("V")) { // if (TV.equals("V"))
TVCost = 40 * (double)days;
//System.out.println(TVCost);
if (phone.equals("T"))
phoneCost = 15 * (double)days;
//System.out.println(phoneCost);
else
phoneCost = X_COST;
//System.out.println(phoneCost);
} // if (TV.equals("V"))
else { // else !(TV.equals("V"))
TVCost = X_COST;
//System.out.println(TVCost);
if (phone.equals("T"))
phoneCost = 15 * (double)days;
//System.out.println(phoneCost);
else
phoneCost = X_COST;
//System.out.println(phoneCost);
} // else !(TV.equals("V"))
} // else if (room.equals("P"))
else { // else
roomCost = 310 * (double)days;
//System.out.println(roomCost);
nurseCost = X_COST;
//System.out.println(nurseCost);
if (TV.equals("V")) { // if (TV.equals("V"))
TVCost = 40 * (double)days;
//System.out.println(TVCost);
if (phone.equals("T"))
phoneCost = 15 * (double)days;
//System.out.println(phoneCost);
else
phoneCost = X_COST;
//System.out.println(phoneCost);
} // if (TV.equals("V"))
else { // else !(TV.equals("V"))
TVCost = X_COST;
//System.out.println(TVCost);
if (phone.equals("T"))
phoneCost = 15 * (double)days;
//System.out.println(phoneCost);
else
phoneCost = X_COST;
//System.out.println(phoneCost);
} // else !(TV.equals("V"))
} // else