I wrote a simple calculator in java, which takes two numbers of type Double from the user and outputs the sum. When I i input the numbers with periods (2.0) I get errors. But when I input with a comma (2,0) it works! It then outputs the answer in the form of 2.0.
Why does my java recognize a double input by comma, but outputs it with a period? The video tutorial I followed, the guy input his double with periods and got it output with periods..
this is my code:
import java.util.Scanner;
public class ScannerIntro {
public static void main(String args[]){
Scanner bucky = new Scanner(System.in);
double firstNumber, secondNumber, answer;
System.out.println("Enter first number: ");
firstNumber = bucky.nextDouble();
System.out.println("Enter Second number: ");
secondNumber = bucky.nextDouble();
answer = firstNumber+secondNumber;
System.out.println("The answer is:");
System.out.println(firstNumber+" + "+secondNumber+" = "+answer);
}
}