Question

please help fill out the class menu create a prototype that will display information about housing...

please help fill out the class menu

create a prototype that will display information about housing data1. In this prototype you will use dynamic array data structures to store the data and compute metrics. For the requirements of the prototype, your client has given you a list of metrics and operations. The user interface will be a menu that displays this list and prompts the user to choose which option to execute.You will create two classes. First you will create your own dynamic array class called MyArray. Your MyArray class will contain a simple Java array called data. You will write methods such that MyArray has the functionality of a dynamic array. Next you will create a class called Menu. Menu will use your MyArray class. The user interface is a menu that displays a list and prompts the user to choose an option. You will write methods to execute each of the menu options. The methods in the Menu class will call the methods in your MyArray class to create dynamic arrays and compute metrics. The template for the Menu class has a stub method for each menu option.Here are additional details where needed:
1. Load objects into an array called myArray1 - Load a plain Java array of survey record objects, plainArray, into a dynamic array called myArray1 - Test: the size of myArray1 = 16688    2. Print the first 5 records 3. Create an array called myArray2 with 5 specified records - Create a dynamic array called myArray2 with the following control numbers:   11041945, 11077809, 11061576, 11007249, 11016540 - Print the final array to the screen   4. In myArray2, insert record 11071287 at index 3 - Print the final array to the screen   5. In myArray2, append record 11033251 - Print the final array to the screen   6. In myArray2, delete record 11077809 - Print the final array to the screen. 7. In myArray2, swap record 11041945 with record 11007249 - Print the final array to the screen   8. Compute how many units there are for each value of totRooms - Create a dynamic array called arrayTotRooms where size = 28, index values will be 0 - 27    - Each element will store the count of records where totRooms equals the index value    - For example, if the number of records where totRooms = 8 is six, then arrayTotRooms[8] = 6 - For categories 1 – 26, compute the average total rooms across all units and store    the result in arrayTotRooms[0] - Test tbd   9. Compute a count of bike records - Create an int called bikeCount that stores the number of records where bike = ‘1’ - Test for myArray1, bikeCount = 75.   10. Create an array containing arrays by decade - Create an array of arrays called arraysByDecade using the variable yrBuilt    - There will be eleven sub-arrays, one for each value in yrBuilt - Test: the size and capacity of the sub-array for 1970 is 2553 and 4096 respectively - Test: the sum of the sizes of the sub-arrays should match the size of myArray1.   11. Create an array of bike record counts by decade - Compute bikeCount for each sub-array in arraysByDecade - Store the counts in an array called arrayBikeCounts - Test: make sure the total across all the sub-arrays matches the result for option 8 above                12. Create an array of condo units - Create a dynamic array called arrayCondoYes that stores the number of records where condo = ‘1’ - Clone myArray1 and shrink it - Test: the size of arrayCondoYes = 1385, the capacity = 4172.---   13. Compute the average number of people per condo - Use arrayCondoYes and the numPeople to compute a double called avgPersonsPerCondo   - Test tbd     14. Sort myArray1 by control number - Sort in ascending order, from smallest to largest
15. Exit   
class Menu {

    private SurveyRecord[] plainArray;
    private MyArray myArray1;
    private MyArray myArray2;
    private MyArray arrayTotRooms;
    private MyArray> arraysByDecade;
    private MyArray arrayBikeCounts;
    private MyArray arrayCondoYes;

    private int bikeCount;
    private Double avgPersonsPerCondo;

    public void option1() {

        //Load a plain Java array of survey record objects, plainArray, into a dynamic array called myArray1
        //Test: the size of myArray1 = 16688
        System.out.println(" stub for option 1 \n");
    }

    public void option2() {

        //Print first five records
        System.out.println(" stub for option 2 \n");
    }

    public void option3() {

        //Create a dynamic array called myArray2 with the following control numbers:
        //11041945, 11077809, 11061576, 11007249, 11016540
        //Print the final array to the screen      
        System.out.println(" stub for option 3 \n");
    }

    public void option4() {

        //In myArray2, insert record 11071287 at index 3
        //Print the final array to the screen
        System.out.println(" stub for option 4 \n");
    }

    public void option5() {

        //In myArray2, append record 11033251
        //Print the final array to the screen
        //use append() function of MyArray.class
        System.out.println(" stub for option 5 \n");
    }

    public void option6() {

        //In myArray2, delete record 11077809
        //Print the final array to the screen
        //use delete() function of MyArray.class
        System.out.println(" stub for option 6 \n");
    }

    public void option7() {

        //In myArray2, swap record 11041945 with record 11007249
        //use swap() and firstIndexOf() functions of MyArray.class
        //Print the final array to the screen
        System.out.println(" stub for option 7 \n");
    }

    public void option8() {

        //Compute how many units there are for each value of totRooms
        //Create a dynamic array called arrayTotRooms where size = 28, index values will be 0 - 27
        //Each element will store the count of records where totRooms equals the index value
        //For example, if the number of records where totRooms = 8 is six, then arrayTotRooms[8] = 6
        //Compute the average total rooms across all units and store the result in arrayTotRooms[0]
        //Test to be determined
        System.out.println(" stub for option 8 \n");
    }

    public void option9() {

        //Compute a count of bike records
        //Create an int called bikeCount that stores the number of records where bike = ‘1’
        //Test for myArray1, bikeCount = 75
        System.out.println(" stub for option 9 \n");
    }

    public void option10() {

        //Create an array containing arrays by decade
        //Create an array of arrays called arraysByDecade using the variable yrBuilt
        //There will be eleven sub-arrays, one for each value in yrBuilt
        //To test, the size and capacity of the sub-array for 1970 is 2553 and 4096 respectively
        //Test: the sum of the sizes of the sub-arrays should match the size of myArray1
        System.out.println(" stub for option 10 \n");
    }

    public void option11() {

        //Create an array of bike record counts by decade
        //Compute bikeCount for each sub-array in arraysByDecade
        //Test: make sure the total across all the sub-arrays matches the result for option 8 above
        System.out.println(" stub for option 11 \n");
    }

    public void option12() {

        //Create an array of condo units
        //Create a dynamic array called arrayCondoYes that stores the number of records where condo = ‘1’
        // Test: the size of arrayCondoYes = 1385
        System.out.println(" stub for option 12 \n");
    }

    public void option13() {

        //Compute the average number of people per condo
        //Use arrayCondoYes and the numPeople to compute a double called avgPersonsPerCondo
        //Test to be determined
        System.out.println(" stub for option 13 \n");
    public void option14() {

       //Sort myArray1 by control number in ascending order, from smallest to largest
        System.out.println(" stub for option 14 \n");
    }

public boolean step() {
        boolean repeatLoop = true;
        while (repeatLoop) {
            System.out.println("\n");
            System.out.println(" 1. Load objects into an array called myArray1");
            System.out.println(" 2. Print the first 5 records");
            System.out.println(" 3. Create an array called myArray2 with 5 specified records");
            System.out.println(" 4. In myArray2, insert record 11071287 at index 3");
            System.out.println(" 5. In myArray2, append record 11033251");
            System.out.println(" 6. In myArray2, delete record 11077809");
            System.out.println(" 7. In myArray2, swap record 11041945 with record 11007249");
            System.out.println(" 8. Compute how many units there are for each value of totRooms");
            System.out.println(" 9. Compute a count of bike records");
            System.out.println("10. Create an array containing arrays by decade");
            System.out.println("11. Create an array of bike record counts by decade");
            System.out.println("12. Create an array of condo units");
            System.out.println("13. Compute the average number of people per condo");
            System.out.println("14. Sort myArray1 by control number");
            System.out.println("15. Exit");
            System.out.println("\n");
            Scanner sd = new Scanner(System.in);
            System.out.print("Enter your choice: ");
            int num = sd.nextInt();
            switch (num) {
                case 1: option1(); break; case 2:option2(); break; case 3:option3(); break; case 4: option4();break; case 5:option5(); break; case 6:option6(); break;case 7: option7(); break;case 8: option8();break; case 9:option9(); break; case 10:option10();break; case 11:option11();break;case 12:option12();break; case 13:   option13(); break;case 14: option14(); break; case 15:
                    repeatLoop = false;
                    break;
            }
        }

        return false;
    }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Load a plain Java array of survey record objects, plainArray, into a dynamic array called myArray1

List myArray1 = (List) Arrays.asList(plainArray);

//Test: the size of myArray1 = 16688

int size=myArray1.size();

//Print first five records

for(int i=0;i<5;i++)
   {
       System.out.println(myArray1.get(i));
   }

//Create a dynamic array called myArray2 with the following control numbers:
        //11041945, 11077809, 11061576, 11007249, 11016540
        //Print the final array to the screen   
   List<Integer>myArray2 =new ArrayList<Integer>();
   myArray2.add(11041945);
   myArray2.add(11077809);
   myArray2.add(11061576);
   myArray2.add(11007249);
   myArray2.add(11016540);
   for(int a: myArray2)
   {
       System.out.println(a);//printing on the screen


   }

//In myArray2, insert record 11071287 at index 3
        //Print the final array to the screen
   myArray2.add(2,11071287);
  
   for(int a: myArray2)
       {
           System.out.println(a);
       }

//In myArray2, append record 11033251
        //Print the final array to the screen
        //use append() function of MyArray.class

myArray2.add(11033251);
  
   for(int a: myArray2)
       {
           System.out.println(a);
       }

       //In myArray2, delete record 11077809
        //Print the final array to the screen
        //use delete() function of MyArray.class

myArray2.remove(11077809);
  
   for(int a: myArray2)
       {
           System.out.println(a);
       }

    //In myArray2, swap record 11041945 with record 11007249
        //use swap() and firstIndexOf() functions of MyArray.class
        //Print the final array to the screen

Collections.swap(myArray2, 11041945, 11007249);
   for(int a: myArray2)
       {
           System.out.println(a);
       }


        //Create a dynamic array called arrayCondoYes that stores the number of records where condo

// Test: the size of arrayCondoYes = 1385

List arrayCondoYes = (List) Arrays.asList(plainArray);

int size=arrayCondoYes .size();

//Sort myArray1 by control number in ascending order, from smallest to largest

Collections.sort(myArray2);
  
   for(int a: myArray2)
       {
           System.out.println(a);
       }
      
  

Add a comment
Know the answer?
Add Answer to:
please help fill out the class menu create a prototype that will display information about housing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include <iostream> using namespace std; template <typename Item> class MyArray{ private:    Item *myarray;    int...

    #include <iostream> using namespace std; template <typename Item> class MyArray{ private:    Item *myarray;    int size;    int used;    void doubleSize(); public:    MyArray();    ~MyArray();    int length();    void insertHead(Item i);    void insertTail(Item i);    void deleteHead();    void deleteTail();    void sortAscending();    void sortDescending();    Item operator [](int i){        return myarray[i];    } }; template <typename Item> MyArray<Item>::MyArray(){    size = 5;    used = 0;    myarray = new Item[size];...

  • Using the following create the nessecary static methods to pass random arrays with the TempartureWithArrays and...

    Using the following create the nessecary static methods to pass random arrays with the TempartureWithArrays and Temperature classes -------------------------------------------------------------------------------------- public class TemperatureWithArrays {    public static final int ARRAY_SIZE = 5;    public static void main(String[] args)    {        int x;        Temperature temp1 = new Temperature(120.0, 'C');        Temperature temp2 = new Temperature(100, 'C');        Temperature temp3 = new Temperature(50.0, 'C');        Temperature temp4 = new Temperature(232.0, 'K');        Temperature tempAve =...

  • Please provide the full code...the skeleton is down below: Note: Each file must contain an int...

    Please provide the full code...the skeleton is down below: Note: Each file must contain an int at the beginning, stating the number of records in the file. Afterwards, the number of records in the file will follow. Each record that follows will consist of a last name (String), and a gpa (double). However, to test the error handling of your program, the number of records will not always match the int value. All possible combinations should be tested. 1.) Prompt...

  • JAVA help Create a class Individual, which has: Instance variables for name and phone number of...

    JAVA help Create a class Individual, which has: Instance variables for name and phone number of individual. Add required constructors, accessor, mutator, toString() , and equals method. Use array to implement a simple phone book , by making an array of objects that stores the name and corresponding phone number. The program should allow searching in phone book for a record based on name, and displaying the record if the record is found. An appropriate message should be displayed if...

  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • Using your Dog class from earlier this week, complete the following: Create a new class called...

    Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...

  • In this lab, you will create a program to help travelers book flights and hotel stays that will b...

    In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...

  • JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate...

    JAVA I. Using the Event Class created previously, create an array of objects;        II. Demonstrate passing array reference to a method;        III. Demonstrate creating array of objects that prints out only x 0.0 for all objects. PROJECT 5C - ARRAYS Create a new file called " EventArray5C". There are some "challenging" directions in this project. . 1.Prepare a document box (tell me that task(s) the application is to accomplish, how it will accomplish the tasks, the author of...

  • Java - Car Dealership Hey, so i am having a little trouble with my code, so...

    Java - Car Dealership Hey, so i am having a little trouble with my code, so in my dealer class each of the setName for the salesman have errors and im not sure why. Any and all help is greatly appreciated. package app5; import java.util.Scanner; class Salesman { private int ID; private String name; private double commRate; private double totalComm; private int numberOfSales; } class Car { static int count = 0; public String year; public String model; public String...

  • A teacher wants to create a list of students in her class. Using the existing Student...

    A teacher wants to create a list of students in her class. Using the existing Student class in this exercise. Create a static ArrayList called classList that adds a student to the classList whenever a new Student is created. In the constructor, you will have to add that Student to the ArrayList. Coding below was given to edit and use public class ClassListTester { public static void main(String[] args) { //You don't need to change anything here, but feel free...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT