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)); } }
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...)]
+ 1
it say user to input integers not double value
use int x = sc.nextInt(); instead of dounle x = sc.nextDouble();