Write a program cmsc401java that receives a sequence of


Write a program cmsc401.java that receives a sequence of commands (from 1 up to 10000 commands)

 a command can be one of: 

1 - an insert – add the date and city to “gig plan”

2 - a ‘date’ query – check if there’s a gig planned at a certain 

date (and if yes, which city)

 3 - a ‘next gig’ query – for the gig found using most recent 

“command 2”, check when and where the next performance is

 4 – end of sequence of commands, quit the program the sequence of commands always ends with Command 4 Command 3 always is preceded immediately by Command 2 Command 3 is given only if Command 2 returned data & city  (that is, there was a gig planed at a queried date) the sequence of commands is presented at standard input, 

each line is a new command

 format of the commands and responses to them:

1 - insert a gig, 

input format is “1 YYYYMMDD STRING”, no output

YYYYMMDD represents the date – date can by anything in the 21st century

STRING represents the city and is up to 10 characters in length

2 – a ‘date’ query, 

input format is “2 YYYYMMDD”, 

output format is “YYYYMMDD STRING” if there is a gig on that date, or 

“YYYYMMDD NO GIG” if not

3 – a ‘next gig’ query

input format is “3”

output format is data and place of next gig: “YYYYMMDD STRING”, 

or “NO NEXT GIG” if there’s no next gig in database

4 – quit

input format is “4”, no output, program exits

? Use Standard I/O to read input and write the result

? In Java, it’s System.in for input, System.out for output

 

Implement the database as a tree

Only implement the required functionality from the tree Using existing tree code (e.g. Built into Java) is NOT allowed Remember that the state of the database changes with each  insert, and queries correspond to the current state of the database

Only inserts that happened prior to the query count  Inserts will never use the same date more than once  There is only one correct result for each query As always: no other text, comments, questions, prompts  should be printed on standard output

 Prepare the source code as cmsc401.java Put your name, and a short description of  your approach (including which tree  operations are used for each command) as a  comment at the start of the cmsc401.java

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a program cmsc401java that receives a sequence of
Reference No:- TGS0585219

Now Priced at $40 (50% Discount)

Recommended (97%)

Rated (4.9/5)