C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 17, Problem 17.10E
Program Plan Intro
Program Plan:
- Include the required header files.
- Create class Time and a driver program that tests the class.
- The class definition will contain prototypes for member function Time, setTime, printUniversal and printStandard.
- The private integer membershour, minute and second.
Program Description:
This program tests new version of class time and return error indicators from class Time’s set Functions.Here, the class is Time which declares the functions Time(), setTime(), setHour()and setMinute().
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Use python):The instructor of a lower division statistics class has assigned you a task: make a function that takes in a student’s score on a scale from 0 to 100 and assigns a letter grade based on the following grade boundaries.
(Rectangle Class) Create class Rectangle. The class has attributes length and width, each of which defaults to 1. It has read-only properties that calculate the Perimeter and the Area of the rectangle. It has properties for both length and width. The set accessors should verify that length and width are each floating-point numbers greater than 0.0 and less than 20.0. Write an app to test class Rectangle.
THIS IS C#
(Using CPP) Create a class that imitates part of the functionality of the basic data type int. Call the class Int (note different capitalization). The only data in this class is an int variable. Include member function to initialize an Int to 0. Write proper getter & setter functions to initialize it to an int value and to return this when needed. Also write a function to display it (it looks just like an int) and to add two Int values. Write a main program that exercises this class by creating one uninitialized and two initialized Int values, adding the two initialized values and placing the response in the uninitialized value, and then displaying this result. Save the file as Int.cpp.
Chapter 17 Solutions
C How to Program (8th Edition)
Ch. 17 - (Scope Resolution Operator) Whats the purpose of...Ch. 17 - (Enhancing Class Time) Provide a constructor thats...Ch. 17 - (Complex Class) Create a class called Complex for...Ch. 17 - (Rational Class) Create a class called Rational...Ch. 17 - Prob. 17.7ECh. 17 - Prob. 17.8ECh. 17 - Prob. 17.9ECh. 17 - Prob. 17.10ECh. 17 - (Rectangle Class) Create a class Rectangle with...Ch. 17 - (Enhancing Class Rectangle) Create a more...
Ch. 17 - Prob. 17.13ECh. 17 - (Hugelnteger Class) Create a class Hugelnteger...Ch. 17 - (TicTacToe Class) Create a class TicTacToe that...Ch. 17 - Prob. 17.16ECh. 17 - (Constructor Overloading) Can a Time class...Ch. 17 - Prob. 17.18ECh. 17 - Prob. 17.19ECh. 17 - (SavingsAccount Class) Create a SavingsAccount...Ch. 17 - Prob. 17.21ECh. 17 - (Time Class Modification) It would be perfectly...Ch. 17 - Prob. 17.23ECh. 17 - Prob. 17.24ECh. 17 - (Project: Card Shuffling and Dealing) Use the...Ch. 17 - Prob. 17.26ECh. 17 - (Project: Card Shuffling and Dealing) Modify the...Ch. 17 - (Project: Emergency Response Class) The North...
Knowledge Booster
Similar questions
- (CLO3) Read the following description and answer the following questions about it: Problem Description: A car dealership allows customer to purchase their new cars with different options. At this time, those options are color, model, and air condition, as shown below in class CustomerOrder. Of course, the dealership wants the software to be flexible enough to be able to add more options in the future, if needed. CustomerOrder -carColor: String -carModel: String -hasAirCondition: boolean Q1) Write the full required code in Java to use the Builder design pattern to create class CustomerOrder. Q2) Write a Java main() method to create an object of class CustomerOrder with color "red" and without air condition.arrow_forward(Rectangle Class) Create a class Rectangle with attributes lengthand width, each of which defaults to 1. Provide methods that calculatethe rectangle’s perimeter and area. It has set and get methods for bothlength and width. The set methods should verify that length andwidth are each floating-point numbers larger than 0.0 and less than 20.0.Write a program to test class Rectangle.(Java Programming Language)arrow_forward(Enhancing Class Rectangle) Create a more sophisticated Rectangle class than the one youcreated in Exercise 17.11. This class stores only the Cartesian coordinates of the four corners of therectangle. The constructor calls a set function that accepts four sets of coordinates and verifies thateach of these is in the first quadrant with no single x- or y-coordinate larger than 20.0. The set function also verifies that the supplied coordinates do, in fact, specify a rectangle. Provide member functions that calculate the length, width, perimeter and area. The length is the larger of the twodimensions. Include a predicate function square that determines whether the rectangle is a squarearrow_forward
- (Querying an Array of Invoice Objects) Use the class Invoice provided in the lab assignment to create an array of Invoice objects.Class Invoice includes four properties—a PartNumber (type int), a PartDescription (type string), a Quantity of the item being purchased (type int) and a Price (type decimal).Write a console application that performs the following queries on the array of Invoice objects and displays the results:a) Use LINQ to sort the Invoice objects by PartDescription.b) Use LINQ to sort the Invoice objects by Price.c) Use LINQ to select the PartDescription and Quantity and sort the results by Quantity.d) Use LINQ to select from each Invoice the PartDescription and the value of the Invoice(i.e., Quantity * Price). Name the calculated column InvoiceTotal. Order the results by Invoice value. [Hint: Use let to store the result of Quantity * Price in a new range variable total.]e) Using the results of the LINQ query in Part d, select the InvoiceTotals in the range$200 to…arrow_forward(Enhancing Class Time) Modify the Time class of Figs. 17.4–17.5 to include a tick memberfunction that increments the time stored in a Time object by one second. Write a program that teststhe tick member function in a loop that prints the time in standard format during each iterationof the loop to illustrate that the tick member function works correctly. Be sure to test the followingcases:a) Incrementing into the next minute.b) Incrementing into the next hour.c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).arrow_forward(Perfect Numbers) An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6=1+2+3. Write a functionisPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.arrow_forward
- (In java) Lab6C: Cha-Ching For this lab, use a do-while loop.A sentinel loop is a loop (a special while loop or a do-while loop) that continues to process data until itreaches a specific value(s) that signals that it should stop looping; this special value(s) is usuallyindicated as the condition of the while or do-while loop. A good example of a sentinel loop is the whileloop that you had to write to verify user input in Lab6B, the special values were anything in the range of1 to 1000. Another very common application for this is allowing a user to rerun a program.Please write a very simple program that mimics a bank account. The program should start the user outwith $1000. The program should print out a welcome menu once with the options present for the user.The program should allow the user to make a deposit, withdrawal, and see their current balance.Every time the user deposits or withdraws, the program should show the user their new balance; itshould also ask the user if they want…arrow_forward4. (Prime Numbers) An integer is said to be prime if it is divisible by only 1 and itself. For example, 2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are not. Write a function called isPrime that receives an integer and determines whether the integer is prime or not. Write a test program that uses isPrime to determine and prints all the prime numbers between 1 and 1000. Display 10 numbers per line.arrow_forward(GREATEST COMMON DIVISOR) The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write and test a recursive function gcd that returns the greatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equal to 0, then gcd (x, y) is x; otherwise, gcd (x, y) is gcd (y, x % y), where % is the remainder operator.arrow_forward
- (Square of Asterisks) Write a function that displays a solid square of asterisks whose side isspecified in integer parameter side. For example, if side is 4, the function displays: **** **** **** ****arrow_forward(Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 =1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.Challenge the power of your computer by testing numbers much larger than 1000.arrow_forward(Rectangle Class) Create a class Rectangle with attributes length and width, each of whichdefaults to 1. Provide member functions that calculate the perimeter and the area of the rectangle.Also, provide set and get functions for the length and width attributes. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning