AUTHOR: CSE110 solution// FILENAME: Assignment7.java// SPECIFICATION
AUTHOR: CSE110 solution// FILENAME: Assignment7.java// SPECIFICATION: This class prompts a user to enter a size for the array//and create a NumberCollection object. Then it displays//a menu to a user, and process a requested task accordingly.// YOUR Lab Letter and Name of the TA for your Closed lab// FOR: CSE 110- homework #7- days and time of your class// TIME SPENT: how long it took you to complete the assignment//———————————————————————-*/import java.util.Scanner;import java.text.*;public class Assignment7{public static void main(String[] args){int number, size;String choice;char command;Scanner keyboard = new Scanner(System.in);// ask a user for a array sizeSystem.out.println(“Please enter a size for the array.\n”);size = keyboard.nextInt();// instantiate a NumberCollection objectNumberCollection collection = new NumberCollection(size);// print the menuprintMenu();do{// ask a user to choose a commandSystem.out.println(“\nPlease enter a command or type ?”);choice = keyboard.next().toLowerCase();command = choice.charAt(0);switch (command){case ‘a’: // add a numberSystem.out.println(“\nPlease enter an integer to add.”);number = keyboard.nextInt();if(collection.addNumber(number))System.out.println(“\n” + number + “successfully added.”);elseSystem.out.println(“\n”+ number + ” isalready in the array. ” + number + ” was not added.”);break;case ‘b’: //remove from collectionSystem.out.println(“Please enter an integer to remove.”);number = keyboard.nextInt();collection.remove(number);break;case ‘c’: //displaySystem.out.println(collection.toString());break;case ‘d’: //rangeSystem.out.println(“The rangeis:” +collection.findRange());break;
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
