Important alert: (current site time 10/25/2014 5:08:33 AM EDT)
 

VB icon

Acceleration Computation (Fixed)

Email
Submitted on: 3/4/2004 6:21:59 PM
By: Jonathan Shaffer  
Level: Beginner
User Rating: Unrated
Compatibility: Java (JDK 1.2)
Views: 13776
(About the author)
 
     This program computes the rate of acceleration of an object by imputing the initial and final velocities and the time it took to get there. Please vote if you like.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Acceleration Computation (Fixed)
// Description:This program computes the rate of acceleration of an object by imputing the initial and final velocities and the time it took to get there. Please vote if you like.
// By: Jonathan Shaffer
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=4117&lngWId=2//for details.//**************************************

/***************************************
 *Code Created by Jonathan Shaffer*
 *You may use and edit this code... *
 *Please mention me in your credits *
 *Please email me at jonathan@saved.net*
 *so I know my code is helping people *
 *(Note... I didn`t include a package *
 ***************************************/ 
import java.awt.*;
import java.awt.event.*;
public class Accelerator extends java.applet.Applet implements ActionListener {
 double v1 = 0;
 double v2 = 0;
 double time = 0;
 double a = 0;
TextField txt1 = new TextField("Initial Velocity",30);
TextField txt2 = new TextField("Final Velocity",30);
TextField txt3 = new TextField("Time",30);
TextField txt4 = new TextField("Meters/S ",30);
Button btn1 = new Button(" Compute ");
Button btn2 = new Button(" Reset ");
 public void init() {
 add(txt1);
 add(txt2); 
 add(txt3);
 add(btn1);
 btn1.addActionListener(this); 
 add(btn2);
 btn2.addActionListener(this); 
 add(txt4);
 txt4.setEditable(false);
 
 }
 public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == btn1) {
 double v1 = (double)((Double.parseDouble(txt1.getText())));
 double v2 = (double)((Double.parseDouble(txt2.getText())));
 double time = (double)((Double.parseDouble(txt3.getText())));
 a = (v2 - v1) / time;
 txt4.setText("Meters/S =" + a);
}
 if (source == btn2) {
 txt1.setText("Initial Velocity");
 txt2.setText("Final Velocity");
 txt3.setText("Time");
 txt4.setText("Meters/S ");
 }
else {
}
 }
 
}


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/30/2005 6:04:57 AMBhadru

Thanks for helping me out in Physics
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.