Search code examples
inputdouble

I just started to learn java. I am trying to make a program that takes in decimal. But it gives me error when i enter a decimal


package com.Pramesh;

import java.util.Scanner;

public class PrameshShrestha { public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
    System.out.println("Enter your first number");
    double num1 = input.nextDouble();
    System.out.println("Enter your second number");
    double num2 = input.nextDouble();
    System.out.println("The total is:  " + (num1 + num2));

}

}


Solution

  • To input a double number, for example 2.5 you need to write on the console 2,5