Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java language Objectives of this lab: Students will understand the concept of classes. Students will write the definition of a class. Students will write definitions
java language
Objectives of this lab: Students will understand the concept of classes. Students will write the definition of a class. Students will write definitions of member functions. Students will be able to use setter and getter. Task# 1 Create a class to find the area of a triangle. The class includes: Two data Members: Base and Height. One member function to calculate the area of the triangle. Calculate area using class function. The formula is : % base x height In main: Give each data member a value. Ask and Display the base and height of triangle. Display the area of the triangle in main function. Task# 2 Create a class to display personal information and check if the user is of legal driving age. The class includes: Three data members: o First Name o Last Name Year of birth A bool function to check if the user is old enough to drive a car. In main: Give each data member a value. Display personal information as "Your name is first name last name You were born in birth year" Decide whether the age is a legal driving age or not. If the age is 18 or greater than 18 then the following message should be printed out "You are old enough to drive a car." Otherwise "You are not old enough to drive a car." Task 3 Invoice amount: 58.47 Original inwoice Information Part number: 5678 Description: Paint Brush Quantity: 0 Price: 0.00 Involce amount: 0.00 Create a casa ed Invoice that hardware store might to representan invoice for an item there. An invece should include four places of information ass variables 1. a part number Dype String) 2. a part description (eString) quantity of the item being purchased (type and 4 aprio per tem(double). Yeur chau should have this operator that initializes the foar inte variable Provide a set and aget method for each instance variable In addition provide a method med ett voiceAmount that caulates the lyole meant fie multiplies the quantity by the price per item) then returns the amount a double valu. If the quantity is not positive. It should be set to If the priceperite Is not positive, it should be 0.0 Writeatest application med voice Test that demonstrates the voice's capabilities inte The input value for the quantity and the pricepere must be validated before they can head to set the corresponding instance variable. This should be done both in the stricter and is the appropriate method . The method header format she be public doctile mount Your output should appear as follows Updated invoice information Part number: 5678 Description Paint Brush Quantity: 3 Price: 9.49 Invoice amount: 28.47 Tasku Solution Original invoice information Part number: 1234 Description Harm Chat: 2 Pice: 14.95 Inice met 29 30 Create a des called Petrolpurchase to represent information about the petrok You purchase. The dass should indude the pieces of information in the form of instance variables The station's location (type Srl The type of petrol type String The quantity type int) of the purchase in liters The price per liter double The percentage discount double Provide a wet and a method for each instance variable. In addition, provide a method and purchasAmount that calculates the purchase amount e multiplies the quantity by the price per liter) mini thadhout, then return the amount you had to pay as a double value Write an application class named Petrol that demonstrates the capabilities of Purchase Updated Invoice information Portuber 001234 Description Yellow Hami Quantity 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