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
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
Get step-by-step solutions from verified subject matter experts
