Men iaf... Det blir kompileringsfel...säger: "variabel volume might not have been initialized" på rad 56.
Så det jag behöver er till är självklart att hitta det retarderade felet... :)
Ett stycke javascript-kod:
public class VolymRatblockCylinderKlot{
public static void main(String [] args){
boolean repeat = true;
double radius, lenght, width, height, volume;
final double PI = 3.14159;
char choice;
do{
System.out.println(" Meny\n");
System.out.println("1. Block");
System.out.println("2. Cylinder");
System.out.println("3. Globe");
System.out.println("4. Quit");
System.out.println("What is your choice?");
choice = Keyboard.readChar();
switch (choice) {
case '1':
System.out.println("What is the width of the block?");
width = Keyboard.readDouble();
System.out.println("What is the length of the block??");
lenght = Keyboard.readDouble();
System.out.println("What is the height of the block??");
height = Keyboard.readDouble();
volume = width*lenght*height;
break;
case '2':
System.out.println("What is the radius of the cylinder?");
radius = Keyboard.readDouble();
System.out.println("What is the height of the cylinder?");
height = Keyboard.readDouble();
volume = radius*radius*PI*height;
break;
case '3':
System.out.print("What is the radius of the globe?");
radius = Keyboard.readDouble();
volume = (4*radius*radius*radius*PI)/3;
break;
case '4':
repeat = false;
break;
default:
System.out.println("Bajs");
}
if (choice == '1' || choice == '2' || choice == '3'){
System.out.println("The volume is " + volume + "\n");
}
}while (repeat);
}
}
Här är rad 55-56 som det är fråga om :)
Svar till Dudier_than_Dude [Gå till post]:
Ett stycke javascript-kod:
if (choice == '1' || choice == '2' || choice == '3'){
System.out.println("The volume is " + volume + "\n");
You're awesome!