# Physics Program

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• June 14th, 2009, 10:40 AM
pwngrammer
Physics Program
i need a simple physics formula. F=ma. Please create a program that has you input the mass and the acceleration and return the force. PLEASE i need this by monday. If you can please answer my other thread i need that too. Also add comments to each line of code about what it does with a // and then the cod. Much aprecciated.
• June 14th, 2009, 01:10 PM
Freaky Chris
Re: Physics Program
Code :

```Scanner sin = new Scanner(System.in); double m = sin.nextDouble(); double a = sin.nextDouble();   System.out.println("F = " + (m*a) );```
• June 14th, 2009, 02:46 PM
pwngrammer
Re: Physics Program
thank you but i also need the code for the prompts to enter the numbers for mass and acceleration. thank you in avdance.
• June 14th, 2009, 02:49 PM
Freaky Chris
Re: Physics Program
You are honestly telling me you can't do that. The information is there, and it would have been the first thing you were taught on your course. I have no problem helping people, but you are showing you have done no work at all, and quite frankly I don't want a bunch of retards walking around with Qualifications they don't know a thing about.

Regards,
Chris
• June 14th, 2009, 03:56 PM
pwngrammer
Re: Physics Program
Haha, I love how you ended that with Regards. Anyway, I know how to do it i just want to make sure that i get it right. If i put up the code would you help me with my mistakes?
• June 14th, 2009, 04:01 PM
Freaky Chris
Re: Physics Program
Ye I don't have a problem with that.
I never mind helping.

Chris
• June 14th, 2009, 04:13 PM
pwngrammer
Re: Physics Program
Code :

```public static [B]Force[/B] readInput() { Double a,b,c; System.out.println("Please input mass.); a=SavitchIn.readLineDouble(); System.out.println("Please input acceleration"); Force f = new Force(a,b); return f; }```

How's that? It's a start right.
• June 14th, 2009, 04:14 PM
pwngrammer
Re: Physics Program
aww forgot the savitch.in for the second input sorry.
• June 14th, 2009, 04:16 PM
Freaky Chris
Re: Physics Program
What is savitchIn defined as? (post all your code) that way I can see your Force class too.

You can edit your posts too, and please you code tags [ code ] [ /code ] ( without spaces :P )

Chris
• June 14th, 2009, 04:24 PM
pwngrammer
Re: Physics Program
savitch.In is the java code that can be exchaged for something else. I use Blujay and my computer is pregrammed to accept savitch.In i do not know the exact word. And about the class, that's where i get iffi. Send me a random class and i can make it into the Force class but I'm not sure how to exactly construct a class. I'm really sorry. I have tried but none of the stuff i learn seems to stick.
• June 14th, 2009, 04:26 PM
Freaky Chris
Re: Physics Program
Code :

```class Force{ public Force(double a, double b){ // some code here } }//end of class```

Theres a basic class called force, with a constructor to match your call...
• June 14th, 2009, 04:34 PM
pwngrammer
Re: Physics Program
Code :

```class Force{ public Force(double a, double b){ public int mass; public int acceleration;//is that right? } }//end of class```
• June 14th, 2009, 04:36 PM
Freaky Chris
Re: Physics Program
You can't have global variables defined within a function

Code :

```class Force{ public int mass; public int acceleration;//is that right? public Force(double a, double b){   } }//end of class```
• June 14th, 2009, 04:42 PM
pwngrammer
Re: Physics Program
"you can't have global variables defined within a function"

yeah i totally understood what that meant:cool: So is that all the code. I just put that all together and thats my code?
• June 14th, 2009, 04:52 PM
Freaky Chris
Re: Physics Program
No farm from it, but I'm very confused as to what you are trying to achieve and how you are trying to d it

Chris
• June 14th, 2009, 06:09 PM
pwngrammer
Re: Physics Program
i simply want a program in which it prompts you to enter the mass and the acceleration and then it returns the force. what is hard to understand about that?
• June 14th, 2009, 09:49 PM
Fendaril
Re: Physics Program
I think Chris is confused as to how you want to go about achieving this.
• June 14th, 2009, 10:35 PM
pwngrammer
Re: Physics Program
i just want him to put the code that is required to do the formula for F=ma. If you can please do it and notate it. This is my final project for programming class and i have just barely been getting by. I know now that I am not meant to be a programmer I want to be an Engineer but I aslo want to pass this class. So please just write the code and write what each line does.
• June 14th, 2009, 10:46 PM
pwngrammer
Re: Physics Program
Code :

```public class Force extends Object { private double mass; private double accel; private double force; public [B]Force[/B] { mass=0; accel=0; force=1; } public [B]Force[/B]e(double a, double b) { mass=a; accel=b; force=1; } public static [B]Force[/B] readInput() { double a,b; public static Force readInput() { Double a,b,c; System.out.println("Please input mass.); a=SavitchIn.readLineDouble(); System.out.println("Please input acceleration"); b=SavitchIn.readLineDouble(); Force f = new [B]Force[/B](a,b); return f; }   public void [B]showData[/B]() { System.out.[B]println[/B]("The force is "+force); }```
• June 14th, 2009, 10:54 PM
Fendaril
Re: Physics Program
Code :

```Class Force { Public int CalculateForce(double first, double second) { return first * second } Public Static void main(String args[]) { Force formula=new Force(); Scanner read=new Scanner(System.in) double a=0 double b=0 a=read.nextDouble(); b=read.nextDouble(); system.out.println("The Force is " + formula.CaclulateForce(a,b)); } }```

Im not cut out to be a programmer either. Actually nobody is. It just depends on how much effort you put in. Study outside of class.

your above code included alot of uneccessary stuff. This is the simplest most straightforward solution.
• June 14th, 2009, 10:58 PM
pwngrammer
Re: Physics Program
Thank You! Is that everything. I have tried studying out of class but the website feel so cluttered and its hard to understand but I'll keep trying. I greatly appreciate this!
• June 14th, 2009, 10:59 PM
Fendaril
Re: Physics Program
That is everything.
• June 14th, 2009, 11:03 PM
pwngrammer
Re: Physics Program
Sorry to bother again but when i try to compile it stops me at double a=0 and it says ";" expected so i added the semicolon but it still says the same thing. any ideas.
• June 14th, 2009, 11:04 PM
Fendaril
Re: Physics Program
Code :

```Class Force { Public int CalculateForce(double first, double second) { return first * second; } Public Static void main(String args[]) { Force formula=new Force(); Scanner read=new Scanner(System.in) double a=0; double b=0; a=read.nextDouble(); b=read.nextDouble(); system.out.println("The Force is " + formula.CaclulateForce(a,b)); } }```

here ya go. Sorry its late and I forgot the semi-colons.
• June 14th, 2009, 11:06 PM
pwngrammer
Re: Physics Program
it still wont work the semi colon is there but it doesnt work
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last