Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program for simulating the fortune unix command. The file that contains fortunes uses % in a single line to separate fortune statements. The

Create a program for simulating the fortune unix command. The file that contains fortunes uses % in a single line to separate fortune statements. The fortune command mist parse the file and represent in memory and then select at random one statement and print that every time invoked.We assume that the contents of the file fit in memory properly and is not too big.

If empty statement in the fortune file is empty then if that statement is selected at random, an empty string must be printed.

Statements may be multiline and they should be printed verbatim if that is the case.

As an example:

Your fortune is bad today!

%

No Fortune Today! Sorry.

%

Today is a good day...

To play the lottery

%

%

Sorry not much fortune today!

%

There are 5 statements above so your program must parse the file and find that out and store the string in some data structure then select a number between 0 and 4 if 2 is selected the following must be printed:

Today is a good day...

To play the lottery

In java

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

Students also viewed these Databases questions

Question

Who should apply a scorecard approach?

Answered: 1 week ago