Find mistake in this coding | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Find mistake in this coding

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner cal : new Scanner (System.in); System.out.println("Enter First Value for addition :-") double a : cal.nextDouble( ); System.out.println("Enter Second Value for addition :-") double b : cal.nextDouble( ); double c : a+b; System.out.println("Your Answer is "+c) } }

25th Jul 2017, 9:22 AM
Ankit Saini
Ankit Saini - avatar
4 ответов
+ 11
Replace the colon in the Object, and Variable declaration with the equals sign and add the semicolon after each print statement
27th Jul 2017, 2:58 PM
Jihad Naji
Jihad Naji - avatar
+ 3
You must add semicolon (";") at the end of each line, you did it somewhere but not everywhere... also: you need to replace colon with equal sign when you assign the resul of nextDouble function to the variables "a","b" and "c" that's the correct one: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner cal = new Scanner (System.in); System.out.println("Enter First Value for addition :-"); double a = cal.nextDouble( ); System.out.println("Enter Second Value for addition :-"); double b = cal.nextDouble( ); double c = a+b; System.out.println("Your Answer is "+c); } }
25th Jul 2017, 9:31 AM
2_3rr0r5
2_3rr0r5 - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner cal : new Scanner (System.in); System.out.println("Enter First Value for addition :-"); double a : cal.nextDouble( ); System.out.println("Enter Second Value for addition :-"); double b : cal.nextDouble( ); double c : a+b; System.out.println("Your Answer is "+c); } } now it's output is " No Output "
25th Jul 2017, 9:29 AM
Ankit Saini
Ankit Saini - avatar
0
It will be so. You are using double so you need to input two float numbers and add next value under first value in input. examples 2.4 2.5 Output: 4.9 import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner cal = new Scanner (System.in); System.out.println("Enter First Value for addition :-"); double a = cal.nextDouble(); System.out.println("Enter Second Value for addition :-"); double b = cal.nextDouble(); double c = a+b; System.out.println("Your Answer is "+c); } }
25th Jul 2017, 10:03 AM
Ferhat Sevim
Ferhat Sevim - avatar