Here is the deal; I've been doing this program in school and my teacher feels as though he has spent too much time helping me, and he said he has gotten the program to run, but I cannot figure it out, and he won't help me anymore. Everything seems to be in order but I have 9 errors.
Here are the program guidelines:
Task:
Write a program that calculates the volume of a rectangular solid with a length, width and height defined by the user. The user should be allowed to find the volume of multiple rectangular solids.
Conditions:
Use JOptionPane dialog boxes.
A control loop(do while, while) should be used within main() to allow the user to run the program multiple times.
main() should call a introduction method, a get values method and an end program method.
The get values method should call a three parameter calculate method.
Allow the user to enter lengths that contain decimals.
Format the volume to two decimals.
Do not forget System.exit(0);
Here is my code:
import javax.swing.JOptionPane; import java.text.DecimalFormat; import cs1.Keyboard; public class C6R7 { public static void main(String[] args) { //loop it fool do{ //method call introduction(); getvalues(); endprogram(); //char choice String word1, word2; word2 = "yes"; boolean value; //do it again word1 = JOptionPane.showInputDialog(null, "Enter yes to continue: ", "Continue?", JOptionPane.QUESTION_MESSAGE); //equals value = word1.equalsIgnoreCase(word2); }while(value == true); } //-------------introduction--------------------- static void introduction(){ //intro JOptionPane.showMessageDialog(null, "Welcome to the amazing volume calculator...", "Welcome", JOptionPane.INFORMATION_MESSAGE); } //--------------getvalues---------------------- static void getvalues(){ //variables String length, width, height; double lengthp = 0, widhtp = 0, heightp = 0, voulume = 0; //decimal format DecimalFormat fmt = new DecimalFormat("#####.##"); //get values //input length length = JOptionPane.showInputDialog(null, "Enter the length of the figure: ", "Length", JOptionPane.QUESTION_MESSAGE); //input width width = JOptionPane.showInputDialog(null, "Enter the width of the figure: ", "Width", JOptionPane.QUESTION_MESSAGE); //input height height = JOptionPane.showInputDialog(null, "Enter the height of the figure: ", "Height", JOptionPane.QUESTION_MESSAGE); //parse it heightp = Double.parse(height); lengthp = Double.parse(length); widthp = Double.parse(width); //volume volume = (lengthp * widthp) * heightp; //output JOptionPane.showMessageDialog(null, "The volume of the figure is " + volume, "The Volume", JOptionPane.INFORMATION_MESSAGE); } //------------------end program-------------------------------- static void endprogram(){ //byebye JOptionPane.showMessageDialog(null, "Thank you for using the Java Volume Calculator", "Have a nice day!", JOptionPane.INFORMATION_MESSAGE); //end it System.exit(0); } }
Here are my errors:
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:32 : cannot find symbol
symbol : variable value
location: class C6R7
}while(value == true);
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:69 : cannot find symbol
symbol : method parse(java.lang.String)
location: class java.lang.Double
heightp = Double.parse(height);
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:70 : cannot find symbol
symbol : method parse(java.lang.String)
location: class java.lang.Double
lengthp = Double.parse(length);
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:71 : cannot find symbol
symbol : variable widthp
location: class C6R7
widthp = Double.parse(width);
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:71 : cannot find symbol
symbol : method parse(java.lang.String)
location: class java.lang.Double
widthp = Double.parse(width);
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:74 : cannot find symbol
symbol : variable volume
location: class C6R7
volume = (lengthp * widthp) * heightp;
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:74 : cannot find symbol
symbol : variable widthp
location: class C6R7
volume = (lengthp * widthp) * heightp;
^
\\Hsstusvr\2012\hartgrc\Java\C6R7\src\C6R7.java:78 : cannot find symbol
symbol : variable volume
location: class C6R7
"The volume of the figure is " + volume,
^
8 errors
Process completed.