+ 3

I need help in average word length

Case 3 and case5 are fails.

6th Dec 2021, 2:03 PM
Aravind P CSE TCET
11 Antworten
+ 4
You need at the begin of code: import java.util.Scanner;
6th Dec 2021, 2:18 PM
JaScript
JaScript - avatar
+ 2
Hello Aravind P CSE TCET Can you please show us your code?
6th Dec 2021, 2:05 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
hoping you forgot to add import statement. There it asked to round up result so use Math.ceil(a) instead of rounding. And convert result back to int type as edit: (int) Math.ceil(a)
6th Dec 2021, 2:28 PM
Jayakrishna 🇮🇳
+ 1
Add : import java.util.Scanner
6th Dec 2021, 3:04 PM
Strt Tmknsn
Strt Tmknsn - avatar
+ 1
Aravind P CSE TCET I also said cast to int result. (Not meant to change data type) did you cast back result to int? System.out.println( (int) Math.ceil(a) ); Edit: In your above code, you are taking k as double so if one of type is already double then all calculations are already upcasted automatically to double. 2 of your (double) of casting have no effect.
8th Dec 2021, 11:31 AM
Jayakrishna 🇮🇳
0
Average of word length is equal to float(len(word)) I don't know java but use the length method and after getting the size change Data type of it to float
6th Dec 2021, 2:13 PM
Amirreza
Amirreza - avatar
6th Dec 2021, 2:13 PM
Aravind P CSE TCET
0
Already I used import statement
8th Dec 2021, 7:27 AM
Aravind P CSE TCET
0
But the 3rd and 5th case only failed
8th Dec 2021, 7:27 AM
Aravind P CSE TCET
0
If using Math.ceil(a) for rounding,the all test cases are failed
8th Dec 2021, 7:35 AM
Aravind P CSE TCET
0
And also changed datatype to int
8th Dec 2021, 7:36 AM
Aravind P CSE TCET