1.
A company wants to transmit data over the telephone, but is concerned 
that its phones could be tapped. All of the data are transmitted as 
four-digit integers. The company has asked you to write a program 
that encrypts the data so that it can be transmitted more securely. 
Your program should read a four-digit integer and encrypt it as 
follows: Replace each digit by (the sum of that digit plus 7) modulus 
10. Then, swap the first digit with the third, swap the second digit 
with the fourth and print the encrypted integer.
2.
A parking garage charges a £2.00 minimum fee to park for up to three 
hours. The garage charges an additional £0.50 per hour for each hour 
or part thereof in excess of three hours. The maximum charge for any 
given 24-hour period is £10.00. Assume that no car parks for longer 
than 24 hours at a time. Write a program that calculates and prints 
the parking charges for each of three customers who parked their cars 
in this garage yesterday. You should enter the number of hours parked 
for each customer. Your program should print the results in a neat 
tabular format and should calculate and print the total of 
yesterday's receipts. The program should use the function 
calculateCharges to determine the charge for each customer. Your 
output should appear in the following format:
Enter the hours parked for three cars: 1.5 4.0 24.0
Car Hours Charge
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
TOTAL 29.5 14.50
Hints:
• Use a for loop to prompt the user for the number of hours parked 
for each of the three customers.
• Declare variables to store the total number of hours and the total 
charges for each customer.
• The variables for all charges and numbers of hours should be of 
type double.
• Function calculateCharges should use a nested if…else statement to 
determine the customer charge.

3.
Package-delivery services, such as FedEx®, DHL® and UPS®, offer a 
number of different shipping options, each with specific costs 
associated. Create an inheritance hierarchy to represent various 
types of packages. Use Package as the base class of the hierarchy, 
then include classes TwoDayPackage and OvernightPackage that derive 
from Package. Base class Package should include data members 
representing the name, address, city, state and ZIP code for both the 
sender and the recipient of the package, in addition to data members 
that store the weight (in ounces) and cost per ounce to ship the 
package. Package's constructor should initialize these data members. 
Ensure that the weight and cost per ounce contain positive values. 
Package should provide a public member function calculateCost that 
returns a double indicating the cost associated with shipping the 
package. Package's calculateCost function should determine the cost 
by multiplying the weight by the cost per ounce. Derived class 
TwoDayPackage should inherit the functionality of base class Package, 
but also include a data member that represents a flat fee that the 
shipping company charges for two-day-delivery service. 
TwoDayPackage's constructor should receive a value to initialize this 
data member. TwoDayPackage should redefine member function 
calculateCost so that it computes the shipping cost by adding the 
flat fee to the weight-based cost calculated by base class Package's 
calculateCost function. Class OvernightPackage should inherit 
directly from class Package and contain an additional data member 
representing an additional fee per ounce charged for overnight-
delivery service. OvernightPackage should redefine member function 
calculateCost so that it adds the additional fee per ounce to the 
standard cost per ounce before calculating the shipping cost. Write a 
test program that creates objects of each type of Package and tests 
member function calculateCost.
4.
Suppose we wish to process survey results that are stored in a file. 
This exercise requires two separate programs. First, create a program 
that prompts the user for survey responses and outputs each response 
to a file. Use an ofstream to create a file called "numbers.txt". 
Then create a program to read the survey responses 
from "numbers.txt". The responses should be read from the file by 
using an ifstream. Input one integer at a time from the file. The 
program should continue to read responses until it reaches the end of 
file. The results should be output to the text file "output.txt". 
[Hint: The second program will use both ifstream and ofstream 
objects, the first for reading responses from numbers.txt and the 
second for writing frequency counts to output.txt.]
5.
Many businesses' Web sites contain shopping-cart applications, which 
allow customers to buy items conveniently on the Web. The sites 
record what the consumer wants to purchase and provide an easy, 
intuitive way to shop online. They do so by using an electronic 
shopping cart, just as people would use physical shopping carts in 
retail stores. As users add items to their shopping carts, the sites 
update the carts' contents. When users "check out," they pay for the 
items in their shopping carts. You must implement a shopping cart 
which allows users to purchase digital satellite receivers from a 
fictitious satellite store that sells four digital satellite 
receivers. Your application may uses four scripts, two server-side 
files and cookies

Reply via email to