public class BTU_Calc_V1 {
// declaring variables
private static int roomnumber;
private static int countr;
private static double length;
private static double width;
private static double height;
private static double volume;
private static double totvolume;
private static char uom;
private static double BTUs;
private static int selection;
private static double totBTUs;
private static double Room_1_BTUs;
private static double Room_2_BTUs;
private static double Room_3_BTUs;
private static double Room_4_BTUs;
private static double Room_5_BTUs;
private static double Room_6_BTUs;
private static char More_Rooms;
public static void main(String[] args) {
System.out.print("Enter the amount of rooms required ");
roomnumber = Keyboard.readInt();
System.out.println("counter="+countr+"roomnumber=" + roomnumber);
while(countr==roomnumber)
{
System.out.print("Enter the unit of measure metres 'M 'or feet 'F' ");
uom = Keyboard.readChar();
for (countr = 1; countr <= roomnumber; countr++) {
System.out.print("What is the length in " + uom + " ");
length = Keyboard.readDouble();
System.out.print("What is the width in " + uom + " ");
width = Keyboard.readDouble();
System.out.print("What is the height in " + uom + " ");
height = Keyboard.readDouble();
volume = length * width * height;
//totvolume = volume + totvolume;
//System.out.println("Volume is " + volume);
System.out.println("");
System.out.println("The Following is a list of room types");
System.out.println("");
System.out.println("1. Bedroom upper floor built \n2. Bedroom upper floor roof \n3. Kitchen upper floor built\n4. Kitchen upper floor roof\n5. Hot room");
System.out.println("");
System.out.print("Chose one of the above");
System.out.println("");
selection = Keyboard.readInt();
switch (uom) {
case 'M': {
if (selection == 1) {
BTUs = volume * 212;
} else if (selection == 2) {
BTUs = volume * 229.54;
} else if (selection == 3) {
BTUs = volume * 247.2;
} else if (selection == 4) {
BTUs = volume * 264.85;
} else {
BTUs = volume * 282.52;
}
totBTUs = BTUs + totBTUs;
if (countr == 1)
Room_1_BTUs = BTUs;
}
if (countr == 2) {
Room_2_BTUs = BTUs;
}
if (countr == 3) {
Room_3_BTUs = BTUs;
}
if (countr == 4) {
Room_4_BTUs = BTUs;
}
if (countr == 5) {
Room_5_BTUs = BTUs;
}
if (countr == 6) {
Room_6_BTUs = BTUs;
}
break;
case 'F': {
if (selection == 1) {
BTUs = volume * 6;
} else if (selection == 2) {
BTUs = volume * 6.5;
} else if (selection == 3) {
BTUs = volume * 7;
} else if (selection == 4) {
BTUs = volume * 7.5;
} else {
BTUs = volume * 8;
}
if (countr == 1)
Room_1_BTUs = BTUs;
}
if (countr == 2) {
Room_2_BTUs = BTUs;
}
if (countr == 3) {
Room_3_BTUs = BTUs;
}
if (countr == 4) {
Room_4_BTUs = BTUs;
}
if (countr == 5) {
Room_5_BTUs = BTUs;
}
if (countr == 6) {
Room_6_BTUs = BTUs;
totBTUs = BTUs + totBTUs;
break;
}
}
System.out.println(countr + " " + roomnumber);
}
System.out.println("Y. Yes \nN. No ");
More_Rooms = Keyboard.readChar();
{
switch (More_Rooms) {
case 'Y': {
roomnumber=roomnumber+1;
System.out.println("counter="+countr+"roomnumber=" + roomnumber);
break;
}
case 'N': {
System.out.println("Room 1 " + Room_1_BTUs);
System.out.println("Room 2 " + Room_2_BTUs);
System.out.println("Room 3 " + Room_3_BTUs);
System.out.println("Room 4 " + Room_4_BTUs);
System.out.println("Room 5 " + Room_5_BTUs);
System.out.println("Room 6 " + Room_6_BTUs);
System.out.println("Total BTUs are " + totBTUs);
break;
}
case 3:
JOptionPane.showMessageDialog(null, "Invald slection please select Y(Yes) or N(No)");
break;
}
}
}
}
}