Question: Problem Build an interactive program to allow a user to interactively allow a user to find out the international radio code for any number of

Problem

Build an interactive program to allow a user to interactively allow a user to find out the international radio code for any number of letters.

When he inputs a letter, display the letter and the corresponding international radio code.

You will be given a file of upper case letters (A-Z) and the corresponding international readio codes in a .csv file. For instance:

A, Alpha

B, Bravo

Requirements

You will one main class firstinitiallastnameInternationalCodes

You will build at least four methods:

The user may input lowercase (a-z), uppercase (A-Z), or garbage.

Filename is from the command line, args[0].

You will need to use the following design tools:

CSCI FileIn, keyBoard, Menu

Two dimensional Arrays, parallel arrays, or class.

String split()

You will use Proper Software Engineering principles.

Proper breakdown into methods

Proper use of data passing between methods.

You will liberally comment the rest of the code explaining your logic.

You will submit a compilable text file firstinitiallastnameInternationalCodes.java so that I can compile and run it.

You will comment the code with a header.

DESIGN

You will want to segment your main program into two parts.

PART 1 will read the data into a data storage method. Choose from one of the methods: multidimensional arrays, stamp data, java classes

Use a While loop and FileIn to get the data.

Part 2. Will loop through displaying a simple menu asking for the users letter or an exit code (say 1).

If he inputs anything else, tell him he made a mistake and go back and try again.

Recommend you use the new CSCI classes Menu and keyBoard for this part.

Once He gives you the letter Display the answer and ask for another input.

Menu code:

package CSCI; import CSCI.*; import java.util.*; // This class is a utility Menu public class Menu{ // class variables private int menuSize; private String[][] menuArray; private final static String STARS = "******************************************"; private final static String BLANK = "* *"; private final static int MAXSIZE = 10; private final static int NUMELEMENTS = 2; private final static int ERROR = 10; private final static String FORMATSTRING = "* %5S %27S *"; // Constructor public Menu(int aMenuSize, String[] Keys, String[] Definitions){ menuArray = new String[NUMELEMENTS][MAXSIZE];// instantiate menuArray if(aMenuSize > MAXSIZE){ System.out.println("** Error ** Expected Menu size " + aMenuSize + " More than " + MAXSIZE + " Items is too many"); menuSize = MAXSIZE; } else menuSize = aMenuSize; // Fill up menuArray for (int i = 0; i < menuSize ; ++i){ menuArray[0][i] = Keys[i]; menuArray[1][i] = Definitions[i]; } } //end Menu public Menu(String Key, String Definition){ menuArray = new String[NUMELEMENTS][MAXSIZE];// instantiate menuArray menuSize = 1; // Fill up menuArray menuArray[0][0] = Key; menuArray[1][0] = Definition; } //end Menu public void project(){ String inLine; print(STARS); print (BLANK); for(int i = 0; i < menuSize; ++i){ inLine = String.format(FORMATSTRING, menuArray[0][i],menuArray[1][i]); print(inLine); } print (BLANK); print(STARS); } // end read public void print(String inLine){ System.out.println(inLine); } public void BuildMenu(){ String inLine; setMenuSize(7); inLine = STARS; print(inLine); }

public void setMenuSize(int Size){ menuSize = Size; }

} //end Menu

Keyboard code:

package CSCI; import CSCI.*; import java.util.*; // This class is a utility Menu public class keyBoard{ // class variables private Scanner Input; private final static int ANINT = 0; private final static double ADOUBLE = 0; private final static char CKEY = 'a';

// Constructor public keyBoard(){ Input = new Scanner(System.in); } public String read(){ String inLine; System.out.print("Type input ==> "); inLine = Input.nextLine(); return inLine; } // end read public String readUpperCase(){ String inLine; String outLine; inLine = read(); outLine = inLine.toUpperCase(); return outLine; } // end readUpperCase public String readLowerCase(){ String inLine; String outLine; inLine = read(); outLine = inLine.toLowerCase(); return outLine; } // end readLowerCase

public char read(char myChar){ String inLine; inLine = read(); myChar = inLine.charAt(0); return myChar; } // end read character public char readLowerCase(char myChar){ myChar = read(myChar); myChar = Character.toLowerCase(myChar); return myChar; } // end readLowerCase public char readUpperCase(char myChar){ myChar = read(myChar); myChar = Character.toUpperCase(myChar); return myChar; } // end readUpperCase public int read(int myInt){ String inLine; inLine = read(); myInt = CSCIConvert.Parse(inLine,myInt); return myInt; } // end read Integer public double read(double myDouble){ String inLine; inLine = read(); myDouble = CSCIConvert.Parse(inLine,myDouble); return myDouble; } // end read Integer public boolean read(boolean myBoolean){ char myChar; myChar = read(CKEY); myBoolean = Parse(myChar,true); return myBoolean; } // end read Integer

public boolean Parse(char value, boolean ERROR){ value = Character.toUpperCase(value); boolean result; switch(value){ case ('T'): case ('Y'): case ('1'): result = true; break; case ('F'): case ('N'): case ('0'): result = false; break; default: result = false; break; } return result; }// end Parse;

} //end Menu

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!