Question: 1. Create a class called Stock with instance variables symbol, totalStock, currentPrice and purchasedPrice. Create a constructor for the class. Include all the accessor and
1. Create a class called Stock with instance variables symbol, totalStock, currentPrice and purchasedPrice. Create a constructor for the class. Include all the accessor and mutator methods. Include the toString and equals method. Also include two other methods called lossOrGain to calculate the amount of the money that the person lost or made. Also include a method call sell that accepts the number of the shares to sell and returns the amount of the money that the person is going to receive. Make sure to create a driver class as well.
2. Create a class called BMI with the following instance variables: name, age, weight(in pounds), and height. Create a constructor for your class so that you can create objects of type BMI. Include all the methods such as accessors, mutators, toString, equals. Also include a method called getBMI which calculates the BMI for the person and returns the BMI. use the following formula. You need to conver the height to meter and the weigh to kilogram. 1 kg = .45 pounds
1 meter = .0254 inches
Bmi = (weight in kg * heigh(in meter)) / (height in meter)* (height in meter)
Also include a method called getStatus to return a String representing the persons status
Bmi < 16 returns seriously underweight
Bmi < 18 returns underweight
Bmi < 24 returns normal weight
Bmi < 29 returns overweight
Bmi < 35 returns seriously overweight
Anything else returns gravely overweight
Also include a driver class to create couple of the objects and output the bmi and the status for each person.
3. Create a class called Account with the instance variables name, id and balance. Include a constructor, accessors, mutators, toString and equals method. Also include a method called transfer so the money can be transferred from one account to another account. Write a method called close accounts and closes the account and return all the money in the account. Create a method called interest that get the interest rate as a parameter and returns the amount of the interest on the balance. Make sure to create a driver class to test your account class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
