Help please | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help please

Hello i am having trouble with tip calculator in java. Sololearn says "the error occurs when the input given by the user is not an intiger. the program expects an integer input for variable x but recives a diffrent data type causing it to crush". I dont really understand what does it want me to do please help :) import java.util.Scanner; public class Program { public static void main(String[] args) { //your code goes here Scanner sc = new Scanner(System.in); System.out.println("how much did u pay today"); double x = sc.nextDouble(); System.out.println("here is with bill money"+(x*15/100)); } }

2nd Nov 2023, 4:27 PM
Djroper r
2 Answers
+ 4
The task doesn't say to output a line with "How much....?" It also says you need an integer, not a double. Does it say to output "here is..."? [And you'd be missing a space after money I.e. "money " + (x...)]
2nd Nov 2023, 8:15 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
it say user to input integers not double value use int x = sc.nextInt(); instead of dounle x = sc.nextDouble();
4th Nov 2023, 12:19 PM
Alhaaz
Alhaaz - avatar