Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, can i get some help with this, im struggling to make it work: You must create two Java files. One is called LastNameFirstNameWeek7Prog.java, and

Hi, can i get some help with this, im struggling to make it work:

You must create two Java files. One is called LastNameFirstNameWeek7Prog.java, and the other is called Business.java. Ensure you include ALL the java files required to make your program compile and run. I would like to see only your .java files.) Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter. Only submit the .java files needed to make the program run. Do not submit the .class file or any other file.

5%

Style Components Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.

5%

LastNameFirstNameWeek7Prog.java Write a driver class that uses the Business class. This driver class will use the main method provided below exactly. You must copy it inside your driver class and not change it. Any change in the main method will deduct points.

public static void main (String[] args) throws Exception { Scanner stdIn = new Scanner(System.in); String name; //Auxiliar Business name String stockTicker; //Auxiliar Business Stock Ticker int numberOfEmployees; //Auxiliar Number OF Employees double netWorth; // Auxiliar net worth

Business a, b, c, d; // Business objects System.out.println("Enter name of first Business"); name = stdIn.nextLine(); System.out.println("Enter Stock Ticker for first Business"); stockTicker = stdIn.nextLine(); System.out.println("Enter Number Of Employees for first Business"); numberOfEmployees = Integer.parseInt(stdIn.nextLine()); System.out.println("Enter Net Worth for first Business"); netWorth = Double.parseDouble(stdIn.nextLine()); a = new Business(name, stockTicker, numberOfEmployees, netWorth);

System.out.println("Enter name of second Business"); name = stdIn.nextLine(); System.out.println("Enter Stock Ticker for second Business"); stockTicker = stdIn.nextLine(); System.out.println("Enter Number Of Employees for second Business"); numberOfEmployees = Integer.parseInt(stdIn.nextLine()); System.out.println("Enter Net Worth for second Business"); netWorth = Double.parseDouble(stdIn.nextLine()); b = new Business(name, stockTicker, numberOfEmployees, netWorth);

System.out.println("Initial set of Business"); System.out.println("a: "+a); System.out.println("b: "+b);

System.out.println("Business a after growth of 10%"); a.grow(); System.out.println("a: "+a);

System.out.println("Businesses b and c, after business b grows 10% and branch out to create c"); c = b.grow().branchOut("Branch of "+b.getName()); System.out.println("b: "+b); System.out.println("c: "+c);

System.out.println("Businesses a, c & d, after creation of d, a joint venture of a and c"); d = a.joinVenture(c); System.out.println("a: "+a); System.out.println("c: "+c); System.out.println("d: "+d);

System.out.println("Businesses a & b, after a takes over b"); a.takeOver(b); System.out.println("a: "+a); System.out.println("b: "+b);

} // end main

This demonstration driver does not call all accessor and mutator methods but it is normal to create them regardless of an immediate use. They may be needed in the future. Sample output is provided below. Be sure to be able to reproduce it.

30%

Business.java Write a Business class inside the Business.java file. This class describe a fictitious Business Company that contains four attributes: the Strings name and StockTicker, the integer numberOfEmployees, and the double netWorth. This class will implement the following methods:

Accessor (get) and Mutator (set) methods for all its attributes.

Default constructor and an Alternate Constructor with parameters for all its attributes.

toString This method will take no parameters. It will return a new String containing all information of the Business object. For example, in the sample output below, the toString method produces the following String for object a: [National Business Machines] Stock Ticker: NBM # of Employees: 1000 Net Worth: 1000000.0

grow This method receives no parameters. It increases the number of employees and the net worth of the current company (this) by 10%. After doing that the method returns the current object (return this).

branchOut This method creates a new Business object that will branch out from the current object. The method receives one parameter: the name of the new Business object. A new Business object must be created inside this method. This new Business objects takes a quarter of the employees and a quarter of the net worth from the current Business (this). The method will subtract the number of employees and money in the parameters from the current object and assign it to a new Business object. The stock ticker for the new Business object will be made of the first character of the name of the new object followed by -, followed by the last character of the name of the new object. The method will return the newly created Business object.

joinVenture This method creates a new Business object that obtains employees and net worth from the current object and another object. The method receives one parameter: a Business object (let us call it b). The method subtracts a quarter of employees and net worth from both, the current object and the Business object b, to be added to the number of employees and net worth of a new Business object that needs to be created. The name of the new Business object is the name of the current object followed by -, and the name of object b. The stock ticker for the new Business object will be made of the first character of the name of the current object followed by &, then followed by the first character of the name of object b. The method will return the newly created Business object.

takeOver This method takes another Business object as a parameter. The current object (this) takes three quarters of the employees and three quarters of the net worth from the Business object in the parameter and return the current object (return this). The Business object parameter will end up with only one quarter of its original employees and net worth.

Do not use Arrays or any other advanced concept that was not reviewed in the class to solve this assignment. Assignments that use these concepts will only be graded 10% for presentation.

55

NOTE: Complete your activity and submit it by clicking Submit Assignment

5%

Total Percentage

100%

Sample Enter name of first Business National Business Machines Enter Stock Ticker for first Business NBM Enter Number Of Employees for first Business 1000 Enter Net Worth for first Business 1000000.0 Enter name of second Business Good Week Inc. Enter Stock Ticker for second Business GWI Enter Number Of Employees for second Business 2000 Enter Net Worth for second Business 4000000.0 Initial set of Business a: [National Business Machines] Stock Ticker: NBM # of Employees: 1000 Net Worth: 1000000.0

b: [Good Week Inc.] Stock Ticker: GWI # of Employees: 2000 Net Worth: 4000000.0

Business a after growth of 10% a: [National Business Machines] Stock Ticker: NBM # of Employees: 1100 Net Worth: 1100000.0

Businesses b and c, after business b grows 10% and branch out to create c b: [Good Week Inc.] Stock Ticker: GWI # of Employees: 1650 Net Worth: 3300000.0

c: [Branch of Good Week Inc.] Stock Ticker: B-. # of Employees: 550 Net Worth: 1100000.0

Businesses a, c & d, after creation of d, a joint venture of a and c a: [National Business Machines] Stock Ticker: NBM # of Employees: 825 Net Worth: 825000.0

c: [Branch of Good Week Inc.] Stock Ticker: B-. # of Employees: 413 Net Worth: 825000.0

d: [National Business Machines-Branch of Good Week Inc.] Stock Ticker: N&B # of Employees: 412 Net Worth: 550000.0

Businesses a & b, after a takes over b a: [National Business Machines] Stock Ticker: NBM # of Employees: 2062 Net Worth: 3300000.0

b: [Good Week Inc.] Stock Ticker: GWI # of Employees: 413 Net Worth: 825000.0

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

More Books

Students also viewed these Databases questions