Skip to content

Conversation

@amira921
Copy link
Owner

@amira921 amira921 commented May 6, 2023

No description provided.


Scanner scanner = new Scanner(file);
int count = 0;
while (scanner.hasNext()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the hasnext depend on white spaces to split the text to tokens so it will count also -- and , as words so try to modify you code to not count them.
aslo you could will be in while loop for infinty becuase it always check for the first word for ever so but scanner.next() in whilc loop to solve the issue

while (scanner.hasNext()) {
count++;
}
System.out.println("The Lincoln file contains " + count + " words.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should print the numer inside the file not in console

Comment on lines 10 to 11
System.out.println("The summation of words: " + file.getSum(path));
System.out.println("The average of words: " + file.getAverage(path));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should print the values inside the file not in console

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As task description the readFromWebToFile method should take url and return a file not a string.
the methods getSum and getAverage should take a file as input not string and return an integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants