Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is for my C++ Class CS 116 Programming Assignment 1: Define a time class named HoursMinutes that will encapsulate time calculations. Store the time
This is for my C++ Class
CS 116 Programming Assignment 1: 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 andm 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, ) 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 ) woulod 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 lh 20 m 5. an addHoursMinutes method that takes an HoursMinutes object as a parameter and adds it to the calling object time, returning a new HoursMinutes object that is the sum of the two times. 6. a scaleHoursMinutes 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 codeStep 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