GeekGirl1979
asked on
Swimming Pool Calcuation Volume and Write to File
this is what I am searching for >>>>>
After each calculation, the collected information and the calculated volume will be saved into a file (or database). You will then add a function to retrieve the input and calculation history from the file or database and display it on the screen.
http://www.devryu.net/ec/courses/33022/CRS-CIS355A-3137905/graphics/week_6_final/swimmingpoolgui.png
the following code is from an expert on here however I do not know how to compile it to see what it looks like
how do you make this a JApplet this code down here. and also add a save button to save the appended text
After each calculation, the collected information and the calculated volume will be saved into a file (or database). You will then add a function to retrieve the input and calculation history from the file or database and display it on the screen.
http://www.devryu.net/ec/courses/33022/CRS-CIS355A-3137905/graphics/week_6_final/swimmingpoolgui.png
the following code is from an expert on here however I do not know how to compile it to see what it looks like
how do you make this a JApplet this code down here. and also add a save button to save the appended text
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class PoolDepth extends JFrame implements ItemListener {
JPanel bottomPanel;
JComboBox shallow;
JComboBox deep;
double depthShallow,depthDeep;
double width = 5.0;
double length = 20.0;
double volume;
final int scalingFactor = 100;
Point topLeft, topRight, bottomLeft, bottomRight;
int[] xPoints, yPoints;
public PoolDepth(){
setResizable(false);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
depthShallow = depthDeep = 0.25;
volume = width * length * ((depthShallow + depthDeep) / 2) ;
topLeft = new Point(20,50);
bottomLeft = new Point(20,(int)depthShallow);
topRight = new Point(380,50);
bottomRight = new Point(380,(int)depthDeep);
xPoints = new int[4];
yPoints = new int[4];
bottomPanel = new JPanel();
bottomPanel.add(new JLabel("Shallow end depth"));
bottomPanel.add(initShallow());
bottomPanel.add(new JLabel("Deep end depth"));
bottomPanel.add(initDeep());
getContentPane().add(bottomPanel,BorderLayout.SOUTH);
pack();
setSize(400,400);
}
public static void main(String[] args){
PoolDepth poolDepth = new PoolDepth();
poolDepth.show();
}
JComboBox initShallow(){
double depth = 0.0;
shallow = new JComboBox();
shallow.addItemListener(this);
for(int i= 0;i < 4;i++){
depth += 0.25;
shallow.addItem(new String(Double.toString(depth)));
}
return shallow;
}
JComboBox initDeep(){
double depth = 0.0;
deep = new JComboBox();
deep.addItemListener(this);
for(int i= 0;i < 12;i++){
depth += 0.25;
deep.addItem(new String(Double.toString(depth)));
}
return deep;
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.blue);
g.fillPolygon(xPoints,yPoints,4);
}
void setPoints(){
// set points clockwise
xPoints[0] = (int)topLeft.getX();
xPoints[1] = (int)topRight.getX();
xPoints[2] = (int)bottomRight.getX();
xPoints[3] = (int)bottomLeft.getX();
yPoints[0] = (int)topLeft.getY();
yPoints[1] = (int)topRight.getY();
yPoints[2] = (int)bottomRight.getY();
yPoints[3] = (int)bottomLeft.getY();
}
public void itemStateChanged(ItemEvent e){
// we're not interested in deselection
if(e.getStateChange() == ItemEvent.DESELECTED){ return; }
String s = (String)e.getItem();
if(e.getSource().equals(shallow)){
// store current shallow end depth
depthShallow = Double.parseDouble(s);
}
else {
// store current deep end depth
depthDeep = Double.parseDouble(s);
}
bottomLeft.setLocation(bottomLeft.getX(),topLeft.getY() + scalingFactor * depthShallow);
bottomRight.setLocation(bottomRight.getX(),topRight.getY() + scalingFactor * depthDeep);
setPoints();
volume = width * length * ((depthShallow + depthDeep) / 2) ;
showVolume();
repaint();
}
void showVolume(){
setTitle(new StringBuffer().append("Pool volume is ")
.append(volume)
.append(" cubic meters")
.toString());
}
}// end class
Your problem is that the applet would have to be signed in order to write to a file
ASKER
Well i guess that wasnt the code i needed.
i still need that calculator that writes to file and shows the results in a pop up panel.
http://www.devryu.net/ec/courses/33022/CRS-CIS355A-3137905/graphics/week_6_final/swimmingpoolgui.png
something like this.
i still need that calculator that writes to file and shows the results in a pop up panel.
http://www.devryu.net/ec/courses/33022/CRS-CIS355A-3137905/graphics/week_6_final/swimmingpoolgui.png
something like this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i dont even know how to do that
Well i can guide you if you want to do it
ASKER
ugh i just paid somebody to do it actually hahaha.....
im pretty much fustrated
im pretty much fustrated
Oh dear - you could have paid me ;-)
ASKER
haha yeah i just spent 50 USD on this indian bloke.
and he is only doing the 70% credit version
not the 100% version...oh well.
and he is only doing the 70% credit version
not the 100% version...oh well.
better off hiring someone more reliable next time :)
can someone guide me thru this swimming pool volume calculator? i see the coding snipit above. However, I want to be able to ask the user for their inputs (length, width, and shallow depth, and deep depth). I know it's a lot more coding when u ask for user inputs...but can anyone help?
ASKER
I need this soon