Practice 6.3 issue | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Practice 6.3 issue

So I did this practice and got all test answers correct except for Test 2, but if I change anything to fix test 2 then all the other tests will be incorrect, what’s going on?

22nd Apr 2021, 6:49 AM
Mohammad Totah
Mohammad Totah - avatar
38 Answers
+ 4
Hi! logically, do you understand why the second test does not pass? do you analyze what the testing program expects from you and what your program outputs?
22nd Apr 2021, 7:27 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
Whoever has done Java 6.3 module subject homework, please let me know if there is an issue with Test Case #2, because it should work
22nd Apr 2021, 7:09 AM
Mohammad Totah
Mohammad Totah - avatar
+ 2
Post the question as well as the answer too
22nd Apr 2021, 6:50 AM
Atul [Inactive]
+ 1
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int math = scanner.nextInt(); int history = scanner.nextInt(); int geometry = scanner.nextInt(); //your code goes here Int minutes = 60; Int hours = 60; System.out.println((math + history + geometry) / minutes); System.out.println(math + history + geometry - hours); } }
22nd Apr 2021, 6:52 AM
Mohammad Totah
Mohammad Totah - avatar
+ 1
Post your question(problem)too
22nd Apr 2021, 6:54 AM
Atul [Inactive]
+ 1
Students are given homework in math, history, and geometry. Write a program that takes the time spent on each subject as input, and calculates and outputs the total number of hours and minutes spent on each subject, each on a new line accordingly.
22nd Apr 2021, 6:54 AM
Mohammad Totah
Mohammad Totah - avatar
+ 1
yes, that's right, this is a verification requirement. and what does your code output?
23rd Apr 2021, 8:34 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
I do understand what it expects from me, but i dont understand what why test2 isnt working
23rd Apr 2021, 2:20 AM
Mohammad Totah
Mohammad Totah - avatar
0
so, what does test #2 expect from you? have you analyzed the output results of your program? what is the result? write it here. and what answer is waiting for test #2? also write it here, in the message
23rd Apr 2021, 6:03 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
First you get to know in which unit the input is given. If hours print hours and then convert it into minutes by multiplying 60 with hours
23rd Apr 2021, 6:15 AM
Atul [Inactive]
0
Input: 40 52 36 Requested output: 2 8
23rd Apr 2021, 8:28 AM
Mohammad Totah
Mohammad Totah - avatar
0
My code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int math = scanner.nextInt(); int history = scanner.nextInt(); int geometry = scanner.nextInt(); int minutes = 60; int hours = 60; System.out.println((math + history + geometry) / minutes); System.out.println((math + history + geometry) - hours); } }
23rd Apr 2021, 8:29 AM
Mohammad Totah
Mohammad Totah - avatar
0
you wrote the task text. go to the task itself, run your code, and see the result. test #2 can be hidden, click on the green check mark. a window opens with the results. what do you see? print them here
23rd Apr 2021, 8:32 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
My code outputs 2 68
23rd Apr 2021, 8:35 AM
Mohammad Totah
Mohammad Totah - avatar
0
2 8 and 2 68 what's wrong here? can you explain?
23rd Apr 2021, 8:37 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
The output has to end with 2 and 8 But im getting 2 and 68 meaning another 60 has to be removed fromthe equation. If i do that all test cases will be incorrect except test2
23rd Apr 2021, 8:40 AM
Mohammad Totah
Mohammad Totah - avatar
0
excellent! you understand that! the extra 60 should be removed!
23rd Apr 2021, 8:41 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
are you familiar with the branch operator?
23rd Apr 2021, 8:42 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Add the inputs and divide it by 60
23rd Apr 2021, 8:43 AM
Atul [Inactive]
0
To get hours
23rd Apr 2021, 8:48 AM
Atul [Inactive]