QuestionQuestion

Create a user defined Company class the class will include Company Name, Stock Symbol and stock value per share. Include a parameterized constructor and get methods for each of the instance variables. Also include a toString method.
Write a program using an arraylist of company names.
• The program will allow the user to enter 10 business names, stock symbol and stock value and display the name and arraylist size.
• Remove each occurrence of Gateway. Display the new arraylist and arraylist size
• Add one addition software company and 2 additional hardware companies. Display the new arraylist and arraylist size
• Display the index of a user input company – Adobe

Determine the average per share price of the final stock list.

Use spacing, alignment, indentation and comments to provide a easily readable code.
Test values: Oracle, Dell, Apple, MicroSoft, Toshiba, Gateway, Adobe, Intuit, SAP, Gateway

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.ArrayList;
import java.util.Scanner;


public class CompanyTester {

public static void main(String[] args)
{
ArrayList<Company> company = new ArrayList<Company>();
Scanner input = new Scanner(System.in);
int count = 0;
while(true)
{
String name, symbol;
double value;
System.out.print("Please enter in the company name: ");
name = input.nextLine();
System.out.print("Please enter in the company stock symbol: ");
symbol = input.nextLine();
System.out.print("Please enter in the value of the stock: ");
value = input.nextDouble();
input.nextLine();
Company temp = new Company(name, symbol, value);
company.add(temp);
System.out.println("Name: " + name + " ArrayList size: " + company.size());
System.out.print("Would you like to enter another company(y/n)? ");
String in = input.nextLine();
if(in.compareTo("n") == 0 || in.compareTo("N") == 0)
break;
}

while(count < company.size())
{
if(company.get(count).getName().compareTo("Gateway") == 0)
company.remove(count);
else
count++;
}...
$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats