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); } }

24th Sep 2021, 7:12 AM
ruiririririri
ruiririririri - avatar
4 Respuestas
+ 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 \
24th Sep 2021, 7:37 AM
Ipang
+ 2
Glad to help 👌
24th Sep 2021, 7:41 AM
Ipang
+ 1
Ipang thank you for your help! Have a nice day!
24th Sep 2021, 7:40 AM
ruiririririri
ruiririririri - avatar