Question: Hello, this is fore programming in the java language. I was given an assignment that is to take in an external file and we are

Hello, this is fore programming in the java language. I was given an assignment that is to take in an external file and we are to find phrases in the file that would signify it to be a duck or duckling or neither. I wrote a code but I got an error. Its a runtime error stating that the if statesments after the 1st are unreachable. I dont know how to fix that and I asked my professor and he told me I need to make three separate methods. One method to find the duck, another method keyCheck to count how many times a certain string occurs within a string, and a method which looks at differences between all lowercase line and regular line. I dont get how to do that so could you please show me what he means by fixing it? This is really hard. Please keep it in this kind of format where we use ifs and whiles and indexOfs, and stuff like that , not higher stuff like .contains. Below is a pic of the original assignment, below that is my program, below that is a picture of what the professor sent me. Thank you so very much!
 Hello, this is fore programming in the java language. I was
given an assignment that is to take in an external file and
we are to find phrases in the file that would signify it
to be a duck or duckling or neither. I wrote a code
but I got an error. Its a runtime error stating that the
if statesments after the 1st are unreachable. I dont know how to
fix that and I asked my professor and he told me I
need to make three separate methods. One method to find the duck,

Program #2 : Calling a Duck a Duck! When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck Write a program to recognize a duck using the above criteria. More precisely, write a program to read lines of up to 80 characters and tell whether that line contains a duck But ducks don't like to come out into the open, so you'll have to check if the line has the words "Waddle" "Swim and "Quack." The words can be in any order, in any case, and may be embedded in other words. There may not be characters embedded within them. As a special case, a line may have a ducking, if all occurrences of the words "Waddle" Swim" and "Quack" are in lower case. HINT: Use nextline to input each line into a string variable, and then use your indexof operation to check for substrings. Sample Program Input (from in file.txt) X- I saw it wadding, swimming, and guacking. ckinsIt waddled, swimmed, and gucked. My, SWIM, SWIM, SWIM, Wadd, lead on, quackers . Swim, swim, little moquackette, waddle home to mother. X Aren't ducks silly? Sample Program Output (to screen) Line 1 is not a duck Line 2 is a duckling Line 3 is not a duck Line 4 is a duck Line 5 is not a duck int Seris

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!