What is the error.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
What is the error.
';' expected. thats all it says
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)); } }
I missed a colon at "Scanner read=new Scanner(System.in)"
now there is an error with the return first * second. it says "possible loss of precision"
Class Force { Public double 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)); } }
Sorry for all those bugs. Im not in front of my ide . Ok try this.
now for Scanner read=new Scanner(System.in); it says cannot find symbol - class Scanner. I'm really sorry for bothering you with all this. You are a really great guy for helping me this much. I hope you know that and I really appreciate it.
Did you import?
import java.util.*;
no. do i put that right before the code?
yes. Hope it works.
that work but now it says cannot find symbol - method CalculateForce(double,double) for system.out.println("The Force is " + formula.CaclulateForce(a,b));
formula.CaclulateForce(a,b));
Typo should be
formula.CalculateForce(a,b));
import java.util.Scanner; public class Force{ public double CalculateForce(double first, double second){ return first * second; } public static void main(String args[]) { double mass = 0; double acceleration = 0; Force formula = new Force(); Scanner read = new Scanner(System.in); System.out.println("Enter Mass: "); mass = read.nextDouble(); System.out.println("Enter Acceleration: "); acceleration = read.nextDouble(); System.out.println("The Force is " + formula.CalculateForce(mass,acceleration)); } }
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.