Learning language is easy but learning basics is difficult
There are two erros here.Enter number of students: 3
Enter student's name: tong
Enter tong 's score:
45
Enter student's name: Michelle
Enter Michelle 's score:
87
Enter student's name: Chris
Enter Chris 's score:
77
Michelle get highest score : 87.0
get lowest score : 77.0
Learning language is easy but learning basics is difficult
Learning language is easy but learning basics is difficult
I tried, the output still sameS Fox wrote:I didn't run it but it looks correct to me, maybe you wanted if (score <= lowestScore) ?
Learning language is easy but learning basics is difficult
Can you tell what's wrong here ?Campbell Ritchie wrote:Oh, I have seen another error, which only affects the low score. Changing < to <= won't make any difference.
Learning language is easy but learning basics is difficult
NotedCampbell Ritchie wrote:Go through the algorithm to work out the highest score, and compare it with the other algorithm, which should be the same but backwards, if you see what I mean.
Learning language is easy but learning basics is difficult
Yes.John Joe wrote:. . . Can you tell what's wrong here ?
![]()
AgreeS Fox wrote:What you can do is . . .
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Enter number of students: 3
Enter student's name: t
Enter t 's score:
34
Enter student's name: w
Enter w 's score:
78
Enter student's name: s
Enter s 's score:
55
t get highest score : 78.0
get lowest score : 34.0
BUILD SUCCESSFUL (total time: 16 seconds)
Learning language is easy but learning basics is difficult
Learning language is easy but learning basics is difficult
Notice that a Scanner can take the input before you print the message: that is normal.java Chapter4
Enter number of students: 3
Enter student's name: Carey 9865329659827365962349574
Enter Carey 's score:
Enter student's name: John 56
Enter John 's score:
Enter student's name: Campbell 3
Enter Campbell 's score:
get highest score : 9.865329659827367E24
Campbell get lowest score : 3.0
S Fox wrote:He will get an NPE if he does what I think you are suggesting fred, then he might be able to read the stack trace to see exactly where his algorithm is broken. Right now he has the worst kind of error, a logic error.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Learning language is easy but learning basics is difficult
Enter number of students: 3
Enter student's name: Tong
Enter Tong 's score: 23
Enter student's name: Michelle
Enter Michelle 's score: 78
Enter student's name: John
Enter John 's score: 45
Michelle get highest score : 78.0
Tong get lowest score : 23.0
Learning language is easy but learning basics is difficult
Afraid not. You haven't corrected the error I found, not even after Carey pointed out what it was. It only shows up if the highest score is entered first.John Joe wrote:Complete Code . . .
DRAGON SWALLOWED HIM... END OF STORY
DRAGON SWALLOWED HIM... END OF STORY
Learning language is easy but learning basics is difficult
Yes?Rafaela Bedim wrote:oi
Learning language is easy but learning basics is difficult