Ex1.

A manufacturing company produces several kinds of goods. Each “good” goes with an “order number”, a “standard price”, and its “availability”. Some goods are perishable, for such goods also a “best before” date needs to be specified. These goods must not be shipped out after 2 days before the “best before” date. However, from eight days before the “bestBeforeDate” the prices of these goods are to be reduced by 50%. After the “bestBeforeDate” they need to be disposed and your program should help to find them then.

The “customers” of the company should also be appropriately represented. Some customers have “Gold status”, since they have ordered for more than £ 2000 in the last month. They receive 5% discounts on their bills.

How do you represent this situation best, how “good”, “order number”, “standard price”, “availability”, “best before”, “customer”, and “gold status”? Are there other aspects to be represented? Is it possible/advisable to make use of subclasses and inheritance? Justify your decisions in appropriate comments and implement a corresponding program (with appropriate tests).

Ex2.

There are essentially two types of students taking this Java module, UG (undergraduate) students and MSc students. Build classes and methods to compute for each student their final mark from component marks and to determine whether they have passed or failed the module. The pass mark for MSc students is 50, for UG students 40. Distinguish exercises, in-class tests and the final examination, worth each a given percentage of the final mark. The percentages must add up to 100%, if they do not the program should give a warning.

(Assume that the individual marks include already possible penalties for late submission.) Note that for individual students certain assignments may be taken out of determining the average since they have been excused by the welfare team for special reasons such as illness.

Avoid duplication of code and make use of inheritance. Your program should contain methods finalMark() (of type int) and hasPassed() (of type boolean).

Ex3.

(a) Declare a class CreditCard with fields name, accountNumber, amount, and limit of appropriate types together with a constructor, and setters and getters for the field variables. Furthermore write a toString method. (The full class would contain other methods, but these are not of concern here.)

(b) The bank wants to offer different types of credit cards, also a GoldCard which has the additional field fee. Write a class GoldCard with a constructor, in which the fee is subtracted from the amount on the creation of objects. Make use of inheritance to reuse the code from part (a).

Ex4.

A patient is told to measure her blood pressure on a daily basis and record the two values (systolic and diastolic) and the day.

systolic diastolic day

94 61 2/5/2013
97 65 3/5/2013
144 99 4/5/2013
123 88 5/5/2013
177 110 6/5/2013
145 89 7/5/2013

The information is stored in an ArrayList as follows:

public class BloodTest {
public static void main(String[] args) {
ArrayList mary = new ArrayList();
mary.add(new Blood(94,61, new Day(2,5,2013)));
mary.add(new Blood(97,65, new Day(3,5,2013)));
mary.add(new Blood(144,99, new Day(4,5,2013)));
mary.add(new Blood(123,88, new Day(5,5,2013)));
mary.add(new Blood(177,110, new Day(6,5,2013)));
mary.add(new Blood(145,89, new Day(7,5,2013)));
printResult(mary);
}
}

Systolic values are too high if they are above 140. Implement a method which prints the highest abnormal systolic blood pressure. If all systolic values are below 140, it should print that no measurement was too high instead. Furthermore it should print the average diastolic blood pressure.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.