Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Hello all I've started Programming since 2 days and I have an assignment to do ; the assignment is """ Write a Java program that takes applied force[N] and mass[kg] of an object from user and calculate its acceleration """"" so here is the code that I wrote """ in the message below
'''' my problem is that the program won't run till giving the FORCE and MASS certain values and what I want from the program to take any value the user gives. what should I do ?

What I have tried:

package physics;


import acm.program.ConsoleProgram;

public class Physics extends ConsoleProgram {
public void run() {

readDouble("Please entre the Force applied ");
double Force =

readDouble("Please entre the Mass");

double Mass=

double acceleration = ( Force/Mass ) ;
println("The accelration is : "+Force/Mass);





}



}
Posted
Updated 28-Oct-17 22:38pm

1 solution

Your readDouble statements are not saving the values that the user enters. In fact the statements following are not even valid Java. You need to capture the returned value of the read statements thus:
Java
double Force = readDouble("Please entre the Force applied ");


See readDouble[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900