why error getting on this line invalid character. int actual_amt=(amt * 10)/100; | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

why error getting on this line invalid character. int actual_amt=(amt * 10)/100;

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amt = scanner.nextInt(); for(int i;i<=3;i++){     int actual_amt=(amt * 10)/100; amt=amt-actual_amt; }System.out.println(amt); } }

27th Dec 2021, 5:02 PM
AYESHA SULTANA
7 Antworten
+ 3
I don't get any Invalid character error, the only thing I see here is that you have not initialized your index in the for loop but that's it.
27th Dec 2021, 5:09 PM
Maz
Maz - avatar
+ 1
Maz There's actually " Error : invalid character '\u00a0' " error. Probably copied code
27th Dec 2021, 5:18 PM
マッドキング♣️✨♣️ [MadKing]
マッドキング♣️✨♣️ [MadKing] - avatar
+ 1
I think I had a similar problem a while ago. If you don't have a perfect integer from that equation, then you have a floating decimal. You could change the int to float or double (remember to add decimals to your numbers) and see how that works.
28th Dec 2021, 9:48 AM
Ausgrindtube
Ausgrindtube - avatar
0
Line 9 : provide an initial value to the variable "i" Like -> for(int i = 0 ; i <= 3 ; i++)
27th Dec 2021, 5:08 PM
マッドキング♣️✨♣️ [MadKing]
マッドキング♣️✨♣️ [MadKing] - avatar
0
dont no i write whole program by myself with different methods still error invalid character.
27th Dec 2021, 5:22 PM
AYESHA SULTANA
0
AYESHA SULTANA rewrite the whole program without any nuisance characters lying around
27th Dec 2021, 5:27 PM
マッドキング♣️✨♣️ [MadKing]
マッドキング♣️✨♣️ [MadKing] - avatar
0
/playground/program. java: error: incompatible types:possible lossy conversation from double to int int actual_amt=(amt *10)/100; error 1
27th Dec 2021, 5:40 PM
AYESHA SULTANA