How to input two doubles in one line for a java calculator

G'day, I'm currently programming a calculator, however, I've been stuck on getting two double variables from one line of user input into a variable

class ComplexNumbers {

private static double sum;

private static double difference;

private static double product;

public static void main(String[] args)


double firstNumbers;

double secondNumbers;

ComplexNumber number1= new ComplexNumber(firstNumbers);

ComplexNumber number2= new ComplexNumber(secondNumbers);

Scanner input = new Scanner(;

System.out.print("*** Basic Arithmetic Operations With Complex Numbers ***");

System.out.println("Enter the complex numbers: "); // e.g. 2.1 -0.1

firstNumbers = input.nextDouble();

System.out.println("Enter the next complex numbers: ");// e.g. 4.3 2.0

secondNumbers = input.nextDouble();`

The plan is to have the output something along the longs...

Read More »

By: StackOverFlow - Monday, 16 April

Related Posts