Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create an ArrayListReview class with one data field of ArrayList and one with LinkedList with the generic type passed to the class. (2 point)

1. Create an ArrayListReview class with one data field of ArrayList and one with LinkedList with the generic type passed to the class. (2 point) 2. Create a constructor that populate an array list and the LinkedList filled with the generic type through inserting new elements into the specified location index-i in the list. (2 points) 3. Write the code to print the No. 50 Fibonacci number. (2 points) 4. A homophone is one of two or more words that are pronounced alike but are different in meaning or spelling; for example, the words two", too", and to". Write a Java program that uses HashMap to find the most words that has the same homophones and return the count of the number of words. (2 points) 5. You have been given the job of creating a new order processing system for the Yummy Fruit CompanyTM. The system reads pricing information for the various delicious varieties of fruit stocked by YFC, and then processes invoices from customers, determining the total amount for each invoice based on the type and quantity of fruit for each line item in the invoice. The program input starts with the pricing information. Each fruit price (single quantity) is specified on a single line, with the fruit name followed by the price. You can assume that each fruit name is a single word consisting of alphabetic characters (AZ and az). You can also assume that prices will have exactly two decimal places after the decimal point. Fruit names and prices are separated by a single space character. The list of fruit prices is terminated by a single line consisting of the text END_PRICES. After the fruit prices, there will be one or more invoices. Each invoice consists of a series of line items. A line item is a fruit name followed by an integer quantity, with the fruit name and quantity separated by a single space. You can assume that no line item will specify a fruit name that is not specified in the fruit prices. Each invoice is terminated by a line consisting of the text END_INVOICE. As a special case, if a line with the text QUIT appears instead of the beginning of an invoice, the program should exit immediately. The overall input will always be terminated by a QUIT line. (5 points)

Implement insertionSort. (5 points) 7. Write the main method to test your program and use System.nanoTime() to find out the speed of each step of your program. (2 point)

8.Given any integer, print an English phrase that describes the integer (e.g. One Thousand, Two Hundred Thirty Four). An ArrayList must be used in your program.

This is what I have until now:

package hw2; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Scanner;

class ArrayListReview { ArrayList list=new ArrayList<>(); LinkedList linkedlist=new LinkedList<>(); ArrayListReview(E data,int index) { list.add(index, data); linkedlist.add(index, data); } public void insert(E data,int index) { list.add(index, data); linkedlist.add(index, data); } public static void yfc(Scanner scan) { Map items=new HashMap<>(); String item=scan.next(); while(item.equals("END_PRICES")) { double price=scan.nextDouble(); items.put(item,price); item=scan.next(); } item=scan.next(); while(item.equals("QUIT")) { double total=0; while(item.equals("END_INVOICE")) { int quantity=scan.nextInt(); total+=quantity*items.get(item); item=scan.next(); } System.out.printf("Total: %.2f ",total); item=scan.next(); } } public static void insertionSort(int arr[]) { int n = arr.length; for (int i = 1; i < n; ++i) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } public static int fibonacci(int n) { if(n==1) return 1; if(n==2) return 1; int a=1,b=1,c; for(int i=2;i { c=a+b; a=b; b=c; } return b; } }

I have to solve them all. They are all part of the same program itself, and below I added what I have so far.

There's not more information, I mean, I copy&paste all the steps of the HW in the top and then I showed the code that I have until now. Even though I send pictures of the document, it will say the same.

So, started from zero or change it with the final code that I created? I think that can be easy start from zero step by step.

I will resubmit a almost finish version, so I think that it will be more easy to handle then.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Define HRM and its relation to organizational management

Answered: 1 week ago