0
Help me spot the error in my code lines
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner cal = new Scanner (System.in); Double fnum, snum, answer; System.out.println ("Enter your first value"); fnum = cal.nextDouble(); System.out.println ("Enter your second value"); snum = cal.nextDouble(); answer = fnum + snum; System.out.println (answer); } } this code is supposed to be a simple addition program but it doesn't seem to work.
2 Respuestas
+ 12
It works just fine.
Maybe you are confused because code playground takes all the values at the beginning before executing the rest of the code.
Input both double values in the window that pops up. One value each line, separated by a line break.
+ 2
Thanks it did work