Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  

Java Code



Share on Google+Share on Google+

Java Code
0 Answer(s)      7 years ago
Posted in : Java Beginners
I need to modify the following code/GUI so that not only does it calculate the volume of a swimming pool, but it tells how much water is needed and how much is costs to fill up the pool if water is .77 cents per cubic foot with a one time cost of $100.00. I just cant figure out how to make the program do those extra calculations. Thanks.

import java.text.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.text.DecimalFormat;

public class PoolVolume {
private JFrame mainFrame;
private JButton calcButton, exitButton;
private JTextField length, width, depth, volume;
private JLabel lengthLabel, widthLabel, depthLabel, volumeLabel;
public PoolVolume() {
mainFrame = new JFrame("Swimming Pool Volume Calculator");
calcButton = new JButton("Calculate volume");
exitButton = new JButton("Exit");
length = new JTextField(5);
width = new JTextField(5);
depth = new JTextField(5);
volume = new JTextField(5);
lengthLabel = new JLabel("Enter the length of the swimming pool: ");
widthLabel = new JLabel("Enter the width of the swimming pool: ");
depthLabel = new JLabel("Enter the depth dept of the swimming pool: ");
volumeLabel = new JLabel("Swimming pool volume: ");
JPanel c=new JPanel(new GridLayout(5,2));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
calcButtonHandler chandler =new calcButtonHandler();
exitButtonHandler ehandler =new exitButtonHandler();
FocusHandler fhandler =new FocusHandler();
class calcButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
DecimalFormat num =new DecimalFormat(",###.##");
Double cLength, cWidth, cdepth, cVolume, Total;
String sLength, sWidth, sdepth, sVolume;
sLength =length.getText();
cLength = Double.parseDouble(sLength);
sWidth =width.getText();
cWidth = Double.parseDouble(sWidth);
sdepth =depth.getText();
cdepth = Double.parseDouble(sdepth);
if(e.getSource() == calcButton) {
Total = cLength * cWidth * cdepth;
String value=volume.getText();
File file = new File("output.txt");
FileWriter fstream = new FileWriter(file,true);
BufferedWriter out = new BufferedWriter(fstream);
out.write("Length= "+sLength+", Width= "+sWidth+", Depth= "+sdepth+" so the volume of Swimming Pool is "+value);
catch(Exception ex){}
class exitButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e){
class FocusHandler implements FocusListener {
public void focusGained(FocusEvent e) {
public void focusLost(FocusEvent e) {
public static void main(String args[]){
new PoolVolume();

View Answers

Related Tutorials/Questions & Answers:
JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
java code
java code  what is the code to turn off my pc through java program
java code
java code  write a java code to convert hindi to english using arrays
java code
java code  hi any one please tell me the java code to access any link i mean which method of which class is used to open any link in java program
java code
java code  need java code for chart or graph which compare the performance of aprior algorithm and coherent rule algorithm.plz any one help me out
java code
java code  write a java code for finding a string in partiular position in a delimited text file and replace the word with the values given by user and write the file in new location
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  I need the java code that would output the following: HARDWARE ITEMS CODE DESCRIPTION UNIT PRICE K16 Wood screws,brass,20mm $7.75 D24 Wood glue,clear,1 liter $5.50 M93
Java code
Java code   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
java code
java code  develop a banking system in java
java code
java code  how to extract html tags using java
java code
java code  HOW TO PRINT 1 TO 100 WITHOUT USING CONDITIONAL,ANY LOOP AND ARRAY IN JAVA AND C.URGENT SIR PLZ  Hi, You can use following code: class MyClass { public static void main(String[] args) { int
java code
java code  what is meaning bufferedreader
java code
java code  what is meaning bufferedreader
java code
java code  i want HSVcolor descriptor for color image in java coding
java code
java code  I am beginer in java my question is how can i fill data from mysql database to jcombobox using netbeans
Java Code
Java Code  Write a java program, which creates multiple threads. Each thread performs add/delete/update operations on an ArrayList simultaneously
java code
java code  hi, Can any one tell me " How to read the data which is present om an image in java
java code
java code  Write a program in java for lru caching using two inputs one using integer and another using string of uppercase only
Java code
Java code  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any... the following code: import java.util.*; import java.text.*; class NumberProgram
java code
java code  int g() { System.out.println("Inside method g"); int h() { System.out.println("Inside method h"); } } Find the error in the following... cannot define a method inside another method. Anyways, we have modified your code
java code
java code  An employee _id consist of 5 digits is stored in a string variable strEmpid. Now Mr.Deb wants to store this Id in Integer type to IntEmpid. write Java statements to do
Java code
Java code   Create a calculator class which will have methods add, multiply, divide & subtract   Hi Friend, Try the following code: class Calculation{ public int add(int a,int b){ return a+b
Java code
Java code  An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus...; Hi Friend, Try the following code: import java.util.*; import
java code
java code  Write a program to find the difference between sum of the squares and the square of the sums of n numbers
java code
java code   Develop a program that accepts the area of a square and will calculate its perimeter
java code
java code  Create a calculator class which will have methods add, multiply, divide & subtract
java code
java code  input any word ie risk,resul is-- r ri ris risk
java code
java code  Develop the program calculateCylinderVolume., which accepts radius of a cylinder's base disk and its height and computes the volume of the cylinder