Write specications for a method within date that advances


Question 1: The price of an item you want to buy is given in dollars and cents. You pay for it in cash by giving the clerk d dollars and c cents. Write speci?cations for a function that computes the change, if any, that you should receive. Include a statement of purpose, the preconditions and postconditions, and a description of the arguments.

Question 2: A date consists of a month, day, and year. Consider the class Date of such dates. Suppose that Date represents the month, day, and year as integers. For example, July 4, 1776, is month 7, day 4, and year 1776.

a. Write speci?cations for a method within Date that advances any given date by one day. Include a statement of purpose, the preconditions and postconditions, a description of the arguments, and a description of any return value.

b. Write a C++ implementation of this method. Design and specify any other method that you need. Include comments that will be helpful to someone who will maintain your implementation in the future.

c. Write a C++ implementation of this method. Design and specify any other method that you need. Include comments that will be helpful to someone who will maintain your implementation in the future.

Question 3: Write a pseudocode function in terms of the ADT appointment book, described in Section 1.4.1, for each of the following tasks. Do you need to add operations to the ADT to perform these tasks?

a. Change the purpose of the appointment at a given date and time.

b. Display all the appointments for a given date.

Question 4: Imagine that you have just left a store with a bag of groceries. You are concerned that the fragile items will not survive the trip home, so when you reach your car, you place those items into their own bag. If Bag is a class of bags, write C++ statements that remove all the items from storeBag and place them into one of two new bags, as follows: Place all occurrences of bread and eggs into fragileBag, and all other items into groceryBag. When you are done, storeBag should be empty. Assume that grocery items are represented by strings.

Question 5: Suppose that a bag contains strings that represent various grocery items. Write a C++ function that removes and counts all occurrences of a given string from such a bag. Your function should return this number. Use comments in javadoc style to fully specify your function. Accommodate the possibility that the given bag is either empty or does not contain any occurrences of the given string.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write specications for a method within date that advances
Reference No:- TGS0958793

Expected delivery within 24 Hours