What is the error.
Printable View
What is the error.
';' expected. thats all it says
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)); } }
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"
Code :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));
Code :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)); } }