[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Swimming Pool Calcuation Volume and Write to File

Posted on 2009-02-20
12
Medium Priority
?
2,319 Views
Last Modified: 2012-05-06
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


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

Open in new window

0
Comment
Question by:GeekGirl1979
12 Comments
 

Author Comment

by:GeekGirl1979
ID: 23698182
my question is how do i get something close to that devry link.

I need this soon
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23699357
Your problem is that the applet would have to be signed in order to write to a file
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23699403
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:GeekGirl1979
ID: 23701040
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.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1500 total points
ID: 23701502
You'll have to sign the applet and make the showVolume method print to file
0
 

Author Comment

by:GeekGirl1979
ID: 23701527
i dont even know how to do that
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23701574
Well i can guide you if you want to do it
0
 

Author Comment

by:GeekGirl1979
ID: 23701695
ugh i just paid somebody to do it actually hahaha.....

im pretty much fustrated
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23701705
Oh dear - you could have paid me ;-)
0
 

Author Comment

by:GeekGirl1979
ID: 23701714
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.  
0
 
LVL 92

Expert Comment

by:objects
ID: 23702905
better off hiring someone more reliable next time :)

0
 

Expert Comment

by:bambino_rubio
ID: 26046144
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?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question