What is wrong in this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is wrong in this?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double amount = scanner.nextInt(); //your code goes here for(i=0;i<3;++i) { amount = (0.9) * amount; } System.out.println(amount); } }

28th Jan 2022, 3:01 PM
Shashi Singh
Shashi Singh - avatar
1 Answer
+ 7
1. Use of .nextInt() method (which reads an `int`) for value assignment of a `double` variable <amount>. Use .nextDouble(). 2. Unspecified data type for variable <i> in the for...loop construct. Define data type for variable <i>.
28th Jan 2022, 3:09 PM
Ipang