Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this question Here's the copy-pastable code: import java.io.IOException; import static java.lang.System.*; public class CoolSet7_1 { public static void main( String args[] )

Need help with this question

image text in transcribed

image text in transcribed

Here's the copy-pastable code:

import java.io.IOException; import static java.lang.System.*; public class CoolSet7_1 { public static void main( String args[] ) throws IOException { String word; FileInput inFile = new FileInput( "coolset7-1.dat" ); word = inFile.readLine(); if( inFile.fileFound() ) { try { while( !inFile.eof() ) { word = inFile.readLine(); FancyWord goal = new FancyWord(word); out.println(goal); out.println(); } }catch( Exception n ) { System.out.println( " End of file" ); } } } }

2. Write program FancyWord to work with the driver program shown below. Notice that each instance of FancyWord, called goal, is displayed by the line out.println(goal) This means that your FancyWord class will have to have a toString method that converts a String matrix (or a matrix of String objects) into a single String object and returns this String object. Keep in mind that a string object can contain escape characters such as " ". import java.io.IOException; import static java.lang.System.; public class CoolSet7_1 public static void main(String args[]) throws IOException coolset 7-1.dat" ); String word; FileInput inFile = new FileInput( word = inFile.readLine(); if( infile.fileFound()) try while( linfile.eof() ) word = inFile.readLine(); FancyWord goal = new FancyWord (word); out.println(goal); out.println(); }catch( Exceptionn) { System.out.println(" End of file"); } atau "coolset7-1.dat" HELLO CAT DOGHOUSE PARANGARACUTIRIMICUARO NEWPORT GOOGLE Basically, when the driver reads a word that word is used to create a FancyWord object. The FancyWord constructor creates a square 2D array (using the number of letters in the word) and fills each String element in the array with a single-letter String object or a space (" "). The toString method uses the elements of the 2D array to form a single String object which is returned to out.print() in the driver and displays an hourglass using this word. SAMPLE OUTPUT PARANGARACUTIRIMICUARO NEWPORT E R WO WO ER NEWPORT Po36. sotda oz a da EE PARANGARACUTIRIMICUARO

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions