Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9 . 1 ( The Rectangle class ) Design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named
The Rectangle class Design a class named Rectangle to represent a rectangle.
The class contains:
Two double data fields named width and height that specify the width and height of the rectangle.
A noarg constructor that creates a rectangle with width and height
A constructor that creates a default rectangle with the specified width and height.
The accessor and mutator functions for all the data fields.
A function named getArea that returns the area of this rectangle.
A function named getPerimeter that returns the perimeter.
Draw the UML diagram for the class. Implement the class. Write a test program that creates two Rectangle objects. Assign width and height to the first object and width and height to the second. Display the properties of both objects and find their areas and perimeters.
The Account class Design a class named Account that contains:
An int data field named id for the account.
A double data field named balance for the account.
A double data field named annualInterestRate that stores the current interest rate.
A noarg constructor that creates a default account with id balance and annualInterestRate
The
accessor
and
mutator functions for id balance, and
annualInterestRate.
A function named getMonthlyInterestRate that returns the monthly interest rate.
A function named withdrawamount that withdraws a specified amount from the account.
A function named deposit amount that deposits a specified amount to the account.
Draw the UML diagram for the class. Implement the class. Write a test program that creates an Account object with an account ID of a balance of and an annual interest rate of Use the withdraw function to withdraw $ use the deposit function to deposit $ and print the balance, the monthly interest.
The Time class Design a class named Time. The class contains:
Data fields hour, minute, and second that represent a time.
A noarg constructor that creates a Time object for the current time.
A constructor that constructs a Time object with a specified elapsed time since the middle of night, Jan in seconds.
A constructor that constructs a Time object with the specified hour, minute, and second.
Three get functions for the data fields hour, minute, and second.
A function named setTimeint elapseTime that sets a new time for the object using the elapsed time.
Draw the UML diagram for the class. Implement the class. Write a test program that creates two Time objects, one using a noarg constructor and the other using Time and display their hour, minute, and second.
Hint: The first two constructors will extract hour, minute, and second from the elapsed time. For example, if the elapsed time is seconds, the hour is the minute is and the second is For the noarg constructor, the current time can be obtained using time as shown in Listing ShowCurrentTime.cpp
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