// we need to import the Scanner, if we
// don't import it, we cannot use it.
import java.util.Scanner;
class jamesprogram {
public static void main(String args[]){
// make variable that will hold the input from
// the keyboard. So whatever we input into
// the system, will be stored in the variable
// froggy
Scanner froggy = new Scanner(System.in);
// declare 3 double variables
double firstnum,secondnum,answer;
System.out.println("Enter first number: ");
// nextDouble() is a method that stores whatever
// number is typed in into firstnum
firstnum = froggy.nextDouble();
System.out.println("Enter second number: ");
// nextDouble() is a method that stores whatever
// number is typed in into secondnum
secondnum = froggy.nextDouble();
answer = firstnum+secondnum;
System.out.println(answer);
}
}
This outputs:
Enter first number:
10.3
Enter second number:
2.9
13.200000000000001