0
[SOLVED] Speed conversion using Java (what is wrong with my code? The compiler said it has some error)
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter the speed (km/h): "); float kph = input.nextFloat(); float mph = kph / 1.60934f; float mps = kph / 3.6f; float yps = kph / 3.2919f; System.out.format("Speed in miles per hour = %.2f\",mph); System.out.format("Speed in meters per second = %.2f\",mps); System.out.format("Speed in yards per second = %.2f\",yps); } }
4 Respostas
+ 3
Where you print <mph>, <mps> and <yps>, you have a backslash \ just before string end quote. I think you meant to have a \n there instead of just a \
+ 2
Glad to help 👌
+ 1
Ipang thank you for your help! Have a nice day!