When finding the speed with integers, the output is displayed correctly, but if you specify, say, time 7.6, the compiler writes an error

import java.util.*; import java.lang.*; import java.io.*; public class Speed { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // TODO Auto-generated method stub System.out.println("Давай-ка посчитаем твою скорость"); System.out.println("Введи время и дистанцию"); System.out.println("Введи дистанцию в метрах"); double distance = sc.nextDouble(); System.out.println("Хорошо, теперь время"); double time = sc.nextDouble(); System.out.println(""); double speed = ((distance/time)*3600/1000); double speed1 = (distance/time); System.out.format("Твоя скорость равна "); System.out.format("%.2f", speed); System.out.println(" км/ч"); System.out.print("или "); System.out.format("%.2f", speed1); System.out.print(" м/с"); } } 

    1 answer 1

    You must set the time through a point: for example, 7.6

    In addition, you can configure the locale so that you can set the time separated by commas, but this, as they say, is another story.