Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.
Project #14.1: A polynomial of degree n has the form:a + bx + cx2 + ... + gxn-1 + hxnThe valuesa, b, c, ..., g, h
are numeric constants called the coefficients of the polynomial, with h != 0. For example:1 + 3x - 7x3 + 5x4is a polynomial of degree 4 with integer coefficents of 1, 3, 0, -7 and 5. Design and implement aPolynomial
class that can represent such a polynomial. Store the coefficients in alist
instance variable of your class. Provide a constructor, an output operation that displays aPolynomial
in easy-to-read format (i.e., using^
to represent exponentiation), an input operation that allows a user a polynomial like that shown above, and an evaluate operation that given anx
-value, returns the value of the polynomial for that value.To test your class, write a program that reads a polynomial and values for
x
and displays the corresponding polynomial values.
Project #14.2: The rock group Flink Poyd is giving a concert and you have been hired by the night club where they are playing. The club seats 100 people, and tickets will be sold in advance. Ticket requests are to be filled in the order in which they are received, with a maximum of four tickets per person. Write anTicketOrder
class that stores a name, address, and number of tickets in a ticket order. Your class should provide input, output, and the equality operations.Using your class, write a program that a box office cashier can use to enter the names, addresses, and number of tickets for a sequence of orders. The orders should be stored in a
list
. Your program should check that no one received more than four tickets, and that the same person does not submit multiple orders. When all the tickets have been ordered (or on a special keyboard input), your program is to generate a series of mailing labels (Name, Address, number of tickets) that a clerk can use to fill the orders.
Project #14.3: Design and implement aBigInt
class whose values are large integers with perhaps hundreds of digits. Represent each number as alist
, each of whose elements is a block of digits of the big integer. Overload the addition and subtraction operators for this class. Do so by adding thelist
s value-by-value, carrying from one element to the next as necessary. Write a two-functionBigInt
calculator to test your program.For some extra fun, overload the multiplication and division operators, too.
Project #14.4: Write aPrint()
library function template that, given alist
, displays each value in thelist
on a separate line. Use an iterator as described in C++ An Introduction to Computing.Add a
Read()
function template that, given alist
, fills it with input values from the keyboard.Using
Print()
andRead()
, overloadoperator<<
andoperator>>
with function templates so thatlist
values can be read and displayed conveniently. Store these functions in the library as well.Add a template for
operator+
that, given twolist
s, returns the concatenation of the twolist
s. Then write a driver program that tests your functions.
Turn the following things: