Question: /*------------------------------------------------------------------------- // AUTHOR: your name // FILENAME: Assignment6.java // SPECIFICATION: This class prompts a user to enter a size for the array // and create




![//----------------------------------------------------------------------*/ import java.util.Scanner; public class Assignment6 { public static void main(String[] args)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e1b5c46b4_59766f4e1b53c915.jpg)
/*------------------------------------------------------------------------- // AUTHOR: your name // FILENAME: Assignment6.java // SPECIFICATION: This class prompts a user to enter a size for the array // and create a CharacterList object. Then it displays // a menu to a user, and process a requested task accordingly. // Your Lab Letter: //----------------------------------------------------------------------*/
import java.util.Scanner; public class Assignment6
{ public static void main(String[] args) {
int size, command; char inputChar; String inputString; Scanner scan = new Scanner(System.in);
// ask a user for a array size System.out.println("Please enter a size for the array. "); size = scan.nextInt();
// instantiate a CharacterList object CharacterList list1 = new CharacterList(size);
// print the menu printMenu();
do
{
// ask a user to choose a command System.out.println(" Please enter a command number, 1, 2, 3, 4, 5, 6, 7, or 8 (to quit)"); command = scan.nextInt(); System.out.println("Entered command: " + command); switch (command) { case 1: // add a character System.out.println(" Please enter a character to add."); inputString = scan.next(); inputChar = inputString.charAt(0); boolean added; /*** ADD YOUR CODE HERE ******************************************************/ if (added == true) System.out.println(inputChar + " was added"); else System.out.println(inputChar + " was not added"); break; case 2: // remove a character System.out.println(" Please enter a character to remove."); inputString = scan.next(); inputChar = inputString.charAt(0); boolean removed; /*** ADD YOUR CODE HERE ******************************************************/ if (removed == true) System.out.println(inputChar + " was removed"); else System.out.println(inputChar + " was not removed"); break; case 3: // display the array /*** ADD YOUR CODE HERE ******************************************************/ break;
case 4: // compute and display the largest /*** ADD YOUR CODE HERE ******************************************************/
if (inputChar == ' ') System.out.println(" The list is empty"); else System.out.println(" The largest character is: " + inputChar); break; case 5: // compute and display the smallest /*** ADD YOUR CODE HERE ******************************************************/ if (inputChar == ' ') System.out.println(" The list is empty"); else System.out.println(" The smallest character is: " + inputChar); break; case 6: // compute and display the sum of unicode System.out.println(" The sum of unicode is: " + list1.computeSumOfUnicode()); break; case 7: printMenu(); break; case 8: break; }
} while (command != 8);
} //end of the main method
// this method prints out the menu to a user public static void printMenu()
{ System.out.print(" Command Options " + "----------------------------------- " + "1: add a character in the array " + "2: remove a character from the array "
+ "3: display the array "
+ "4: compute and display the largest character "
+ "5: compute and display the smallest character " + "6: compute and display the sum of unicode " + "7: display the menu again "
+ "8: quit this program ");
} // end of the printMenu method } // end of the Assignment7 class

Your assignment is to create a class called CharacterList in a file called CharacterListjava. (there is no main method in this class). A class CharacterList has the following instance variables (they must be declared using private) charAmay-an array of characters count an integer The variable count keeps track how many characters are stored in the array. The variable name for the array of characters is charArray. Note: You need to distinguish the array size (capacity) and "count" that keeps track of characters added to this array so far. The class CharacterList must include the following constructor and methods. (If your class does not contain any of the following methods, pointswill be deducted.) Your assignment is to create a class called CharacterList in a file called CharacterListjava. (there is no main method in this class). A class CharacterList has the following instance variables (they must be declared using private) charAmay-an array of characters count an integer The variable count keeps track how many characters are stored in the array. The variable name for the array of characters is charArray. Note: You need to distinguish the array size (capacity) and "count" that keeps track of characters added to this array so far. The class CharacterList must include the following constructor and methods. (If your class does not contain any of the following methods, pointswill be deducted.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
