Java - Property Tax

 
Vista:

Property Tax

Publicado por juan (1 intervención) el 12/12/2009 20:35:55
Design a Java program that creates the content pane to calculate property taxes. You need label fields and text fields to let users enter a home value, school tax rate, and county tax rate; label fields and text fields to display the school tax, county tax , and total taxes; and buttons to calculate and exit the program. You will not process any values.

help for this code

import java.applet.*;
import java.awt.*;
import java.awt.event.*;// end classs
import java.text.DecimalFormat;

public class PropertyTax extends Applet implements ActionListener {



int red = 255;
int blue = 255;
int green = 255;

Color myColor = null;
DecimalFormat decimalFormat = null;


double total, total2, total3;
Label label1, label2,label3,label4, label5, label6, label7, label8, label10;
TextField text1, text2,text3, text4, text5, text6, text7, text8, text10;
Button clicker1;

boolean isStandalone = false;
/**Get a parameter value*/
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}

/**Construct the applet*/
public PropertyTax() {
}
/**Initialize the applet*/
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
myColor = new Color(red, green, blue);
decimalFormat = new DecimalFormat("#######0.00");
setBackground(myColor); //or any predefined colors
Panel pan=new Panel(new GridLayout(10, 10));
setLayout(new BorderLayout());
label1 = new Label ("Assessed Home Value");
label2 = new Label ("Decimal Value of School Tax Rate");
label3 = new Label ("Decimal Value of County Tax Rate");

text1 = new TextField (5);
text2 = new TextField (5);
text3 = new TextField (5);


label8 = new Label ("School Taxes:");
text8 = new TextField (5);
label10 = new Label ("County Tax");
text10 = new TextField (5);
clicker1 = new Button("Calculate");
label6 = new Label ("Totales");
text6 = new TextField (5);
label7 = new Label ("Total");
text7 = new TextField (5);



pan.add(label1);
pan.add(text1);
pan.add(label2);
pan.add(text2);
pan.add(label3);
pan.add(text3);


pan.add(label8);
pan.add(text8);
pan.add(label10);
pan.add(text10);
pan.add(clicker1);
add(pan);
setVisible(true);
clicker1.addActionListener(this);

pan.add(label6);
pan.add(text6);
pan.add(label7);
pan.add(text7);



}
/**Get Applet information*/
public String getAppletInfo() {
return "Applet Information";
}
/**Get parameter info*/
public String[][] getParameterInfo() {
return null;
}
/**Main method*/
public static void main(String[] args) {
PropertyTax applet = new PropertyTax();
applet.isStandalone = true;
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("PropertyTax");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}



public void actionPerformed (ActionEvent e) {
try
{
total = Double.parseDouble(text1.getText()) - Double.parseDouble(text2.getText()) -Double.parseDouble(text8.getText());

total2 = Double.parseDouble(text1.getText()) - Double.parseDouble(text3.getText()) -Double.parseDouble(text7.getText());

total3 =Double.parseDouble(text7.getText())- Double.parseDouble(text8.getText()) -Double.parseDouble(text7.getText());
}
catch( Exception ex )
{
total = 0;
total = 0;
total = 0;

}

text6.setText(""+ decimalFormat.format(total) );
text7.setText(""+ decimalFormat.format(total) );
text8.setText(""+ decimalFormat.format(total2) );
text10.setText(""+ decimalFormat.format(total3) );

}



}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder