Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, this is for programming one with the java language. This assignment is supposed to take an external file and find certain words and phrases

Hello, this is for programming one with the java language. This assignment is supposed to take an external file and find certain words and phrases and distinguish them from each other and return it as a state depending on what it was. There are three cases, a line could be a duck, a duckling, or neither. This code has to be done by scratch and again it has to take in an external file, thank you oh so very much for your help, seriously thank you. image text in transcribed
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 duckling, 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 infile.txt) I saw it waddling, swimming, and quacking It waddled, swimmed, and quacked My, SWIM, SWIM, SWIM, Wadd, lead on, quackers. Swim, swim, little moquackette, waddle home to mother. 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 duchk Line 5 is not a duck

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions