Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Answer Q2(a)-Q2(c) using Java based on the information given in FIGURE Q2. The BinaPaint Company has asked you to write a program that calculates the
Answer Q2(a)-Q2(c) using Java based on the information given in FIGURE Q2. The BinaPaint Company has asked you to write a program that calculates the price of painting for rectangular walls. To calculate the price, you multiply the area of the wall (length times width) by the price per square metre of wall, For example, the area of wall that is 15 metres long and 12 metres wide is 180 square metres. To paint that wall that costs RM20 per square metre would cost RM3,600.00 (15x12x20 = 3,600) You are required to apply three classes: WallDimension, Wallpaint, and PaintCalculator. The PaintCalculator contains the main method that will apply WallDimension and wallpaint classes. The following UML diagram shows possible class design and the relationships between the wallDimension class and WallPaint class. WallPaint - size: WallDimension paint Cost: double +WallPaint (dim: WallDimension, cost: double) +get Total ost(): ouble +toString(): String WallDimension length: double - width: double +WallPaint (dim: WallDimension, cost: double) +get Total cost(): double +toString(): String FIGURE Q2 (a) Write a class named wallDimension that has two fields: one for the length of the wall and one for the width. The WallDimension class should have a method that returns the area of the wall. The area of the wall is the wall's length multiplied by the wall's width. (15 marks) (b) Write a class named WallPaint that has a WallDimension object as a field. The WallPaint class should also have a field for the cost of the wall per square metre. The Wallpaint class should have a method that returns the total painting cost of the wall. (15 marks) (c) Write an application class, namely PaintCalculator that will use the classes implemented for Q2(a) and Q2(b). Prompt the user to enter the dimensions of a wall and the price per square metre of the desired painting. The application should display the total painting cost of the wall (15 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started