Pass and fail problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pass and fail problem

Problem: If my input is 1 70, then it should say pass, if my input is 1 60 its should say fail... Right now, it says pass when i type in 1 70 70, but it should only ask for 1 70, not 2 70's, UNLESS my first int is 2, then it should ask for 2 70's Errors: it gives me an error if my 1 doesnt have 2 following integers, it should only have 1. it gives me sn error whenever i start with 2, no matter the amount of integers afterwards. I have been struggeling with this code for over 2 days now, and i just cant seem to get it working, no matter how i change the code... Here is my code: https://code.sololearn.com/c3LMJKHQ9VOh/?ref=app

4th Nov 2018, 8:27 PM
Stephen Van Der Westhuizen
Stephen Van Der Westhuizen - avatar
6 Answers
0
hi Stephen, i have improve your code to the fast. it run without error look for scanner methods hasNext... and next... and their description https://code.sololearn.com/cOnY1bU2f0Sy
4th Nov 2018, 10:31 PM
asa22
0
asa22 Thank you so much! This was really helpful!
5th Nov 2018, 5:15 AM
Stephen Van Der Westhuizen
Stephen Van Der Westhuizen - avatar
0
asa22, the code has a problem, and i dont understand why, whenever i type in: 1 70 (or more than 70) The the output if 'fail', but then i put in anything less than 70, it says 'no output'
5th Nov 2018, 12:17 PM
Stephen Van Der Westhuizen
Stephen Van Der Westhuizen - avatar
0
asa22, the code has a problem, and i dont understand why, whenever i type in: 1 70 (or more than 70) The the output is 'fail', but then i put in anything less than 70, it says 'no output'
5th Nov 2018, 12:17 PM
Stephen Van Der Westhuizen
Stephen Van Der Westhuizen - avatar
0
sorry, i don’t get a message about your post. i use a linebreak for the input data i ask explicit if (numbs.hasNextLine()) { numbs.nextLine(); input : 1 return 70 return ..... if you want to input the data in one line, you have to change the program, with this..... Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { System.out.println(scanner.nextInt()); }
7th Nov 2018, 6:03 PM
asa22
7th Nov 2018, 6:35 PM
asa22