See below
The blanks can easily be filled with a little typing aided by copy and paste from other parts of the program.
import java.util.Scanner;
public class AddDoubles
{
public static void main (String[] args)
{
double first, second, sum;
Scanner scan = new Scanner( System.in );
// Read in the first double
System.out.print("Enter the first double: ");
first = scan.nextDouble();
// Read in the second double
System.out.print("Enter the second double: ");
second = scan.nextDouble();
// Compute the sum and write it out
sum = first + second;
System.out.print("Sum: " + sum );
}
}
Here is a run of the program:
C:\temp>java AddDoubles Enter the first double: 10.59 Enter the second double: 8.02 Sum: 18.61
(Thought Question: ) Could the variable sum be
eliminated from this program?