Define a time class named HoursMinutes that will encapsulate time calculations. Store the time in a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Define a time class named HoursMinutes that will encapsulate time calculations. Store the time in a single private data member named totalMinutes. The class should provide the following methods: 1. a Constructor that takes two integer parameters named h and m that represent the desired hours and minutes. The minutes parameter does not need to be restricted to < 60. A time of two hours can be constructed as HoursMinutes (2, 0) or HoursMinutes (0, 120). Keep this in mind when writing the add method. 2. a getHours method returning an integer that is the whole number of hours. 3. a getMinutes method returning an integer that is the number of minutes remaining after the whole number of hours. Example: if time t is constructed as HoursMinutes (1, 20) then the totalMinutes data member would store 80, t.getHours () would return 1 and t.getMinutes() would return 20. 4. a printHoursMinutes method that prints the time. For the time t described above, it would print 1 h 20 m. 5. an addHours Minutes method that takes an HoursMinutes object as a parameter and adds it to the calling object time, returning a new Hours Minutes object that is the sum of the two times. 6. a scaleHours Minutes method that takes an integer as a parameter and multiplies the calling object time by the integer, returning a new HoursMinutes object that is the scaled time. Write a main function that creates two time objects, prints them then adds the two times and prints the result. Also, use the scaling method to double the first time and triple the second time and print the results. For this assignment you do not need to separate the class definition and implementation into separate parts of the program or separate files. For now, we can restrict things to positive times only. I have provided two sample classes for feet and inches objects. The 2nd program uses some advanced features we will learn later, but if you have some programming experience, you can try adding them to your code. Define a time class named HoursMinutes that will encapsulate time calculations. Store the time in a single private data member named totalMinutes. The class should provide the following methods: 1. a Constructor that takes two integer parameters named h and m that represent the desired hours and minutes. The minutes parameter does not need to be restricted to < 60. A time of two hours can be constructed as HoursMinutes (2, 0) or HoursMinutes (0, 120). Keep this in mind when writing the add method. 2. a getHours method returning an integer that is the whole number of hours. 3. a getMinutes method returning an integer that is the number of minutes remaining after the whole number of hours. Example: if time t is constructed as HoursMinutes (1, 20) then the totalMinutes data member would store 80, t.getHours () would return 1 and t.getMinutes() would return 20. 4. a printHoursMinutes method that prints the time. For the time t described above, it would print 1 h 20 m. 5. an addHours Minutes method that takes an HoursMinutes object as a parameter and adds it to the calling object time, returning a new Hours Minutes object that is the sum of the two times. 6. a scaleHours Minutes method that takes an integer as a parameter and multiplies the calling object time by the integer, returning a new HoursMinutes object that is the scaled time. Write a main function that creates two time objects, prints them then adds the two times and prints the result. Also, use the scaling method to double the first time and triple the second time and print the results. For this assignment you do not need to separate the class definition and implementation into separate parts of the program or separate files. For now, we can restrict things to positive times only. I have provided two sample classes for feet and inches objects. The 2nd program uses some advanced features we will learn later, but if you have some programming experience, you can try adding them to your code.
Expert Answer:
Answer rating: 100% (QA)
Heres an implementation of the HoursMinutes class in Python python class HoursMinutes def initself h ... View the full answer
Related Book For
Thomas Calculus Early Transcendentals
ISBN: 9780321884077
13th Edition
Authors: Joel R Hass, Christopher E Heil, Maurice D Weir
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
see below questions and provide me adjusted coding by using my coding. I share my coding and test failure message at the end. 1. BST.java 2.BSTNode.java Binary Search Tree you will be coding the...
-
Using the sinking fund Table 13.3, complete the following: Note: Do not round intermediate calculations. Required amount $ Frequency of Length of payment time 8 years 15,000 Annually Interest rate 8...
-
A camp counselor wants to make a smoothie for a group of children using at most 75 pounds of fruit consisting of oranges, cherries, and blueberries. Each pound of oranges contains 230 calories, 3 mg...
-
Differentiate the following terms/concepts/individuals: a. IQ and EQ b. Mood and emotion c. Human brain and the brain of other animals d. Phineas Gage and Elliot
-
Obtain a photograph/image of a flow in which it would not be appropriate to use the Bernoulli equation. Print this photo and write a brief paragraph that describes the situation involved. Bernoulli...
-
The following control procedures are used at Aldean Company for over-the-counter cash receipts. 1. To minimize the risk of robbery, cash in excess of $100 is stored in an unlocked attach case in the...
-
Fluid mechanics NUMERICAL PROBLEMS (4 X 3 = 12 Points) Q1. An oil flows through 50.0 m of cast iron pipe having a diameter of 0.25 m. If the volumetric flow is 0.40 m^3/s, determine the head loss in...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
What is the matrix representation of the relation RS, where R and S are relations on the set {a, b, c, d] such that R = {(a,b), (a, d), (b, c), (c, c), (d, a)} and S = {(a, c), (b, c), (b,d), (c,b),...
-
Gerhan Company's flexible budget for the units actually manufactured in May shows $15,640 of total factory overhead; this output level represents 70% of available capacity. During May the company...
-
The term of this Lease Agreement is for a period commencing on the 1st day of April, Year 3, through the 31st day of March, Year 4. Base Rate and Utilities: Subject to the provisions of this Lease...
-
What nuanced strategies can be employed to navigate the complexities of multitasking, ensuring that simultaneous responsibilities are managed with finesse and without compromising quality?
-
Gender differences are challenging and evoke many feelings based on one's values, beliefs, culture, and societal acceptance. Create 2 Literature Reviews on Gender Differences .Use scholarly articles...
-
Reporting of items (e.g., discontinued operations) within an accounting period on the income statement or statement of retained earnings net of tax. Such allocation relates the income tax expense of...
-
Create a class called BrainLobeGUI. This class should extend JComponent. Create a class called Lobe. Create a class called MainLobeGUI. This class should contain a main method. You may add any number...
-
A fuel pump sends gasoline from a car's fuel tank to the engine at a rate of 5.88 10-2 kg/s. The density of the gasoline is 735 kg/m3, and the radius of the fuel line is 3.18 10-3 m. What is the...
-
Find the center of mass and the moment of inertia about the z-axis of a thin shell of constant density cut from the cone x 2 + y 2 - z 2 = 0 by the planes z = 1 and z = 2.
-
Give information about the foci, vertices, and asymptotes of hyperbolas centered at the origin of the xy-plane. In each case, find the hyperbolas standard-form equation from the information given....
-
Find the limit of each function (a) As x and (b) As x -. h(x) = 3 - (2/x) 4 + (2/x)
-
Following is a list of information for Peter and Amy Jones for the current tax year. Peter and Amy are married and have three children, Aubrynne, Bryson, and Caden. They live at 100 Main Street,...
-
Kelly and Chanelle Chambers, ages 47 and 45, are married and live at 584 Thoreau Drive, Boston, MA 59483. Kellys Social Security number is 111-11-1111 and Chanelles is 222-22-2222. The Chambers have...
-
The amplitude of a surface wave for which \(\lambda=0.050 \mathrm{~m}\) is \(5.0 \mathrm{~mm}\) at a distance of \(1.0 \mathrm{~m}\) from a point source. What is the amplitude of the wave (a) 10 m...
Study smarter with the SolutionInn App