Question

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 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++;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Hangman Game Using Arrays
Homework Solution
$33.00
Computer Science
Game Development
Arrays
Programming
Java
Words
Codes
Letters
Hangman
Characters
Guessing
Input
Output
Drawing
Java & UML Programming Problems
Homework Solution
$20.00
Java
UML
Programming
Coding
Computer Science
Fraction
Denominator
Numerator
Big Integers
Printing Outputs
Decimal Values
Arithmetic Operations
Interactive Command-Line Game in Java
Homework Solution
$50.00
Java
Programming
Coding
Game Development
Computer Science
Zork
Colossal Cave Adventure
Command Line
Maps
2D Grid
Win
Lose
Classes
OOP
Methods
Fields
String Values
Integers
Statements
Java Problems: Euclidean Distance and Arrays
Homework Solution
$20.00
Java
Programming
Computer Science
Coding
Euclidean Distance
Reversing an Array
String Values
Integer Values
Boolean Arrays
Input
Output
Square Root
Sum of Squares
Mathematics
Vectors
Rows
Columns
Odd Numbers Problem in Java
Homework Solution
$10.00
Java
Programming
Computer Science
Mathematics
Integers
Odd Values
Even Values
Output
Input
Range
Loops
Conditions
Statements
Samples
Arrays in Programming Language Java
Homework Solution
$20.00
Java
Programming
Computer Science
Arrays
Integers
Random Numbers
Methods
Functions
Even Elements
Odd Elements
Prime Numbers
Minimum Values
Maximum Values
Average Values
Loops
Conditions
Statements
Get help from a qualified tutor
Live Chats