Sunteți pe pagina 1din 4

Task 1:

Task 2:

Task 3:

Task 4:

Task 5:

Task 6:
Task 7:
Write a program that prompts the user to enter the weight of a person in
kilograms and outputs the equivalent weight in pounds. Output both the
weights rounded to two decimal places. (Note that 1 kilogram 2.2
pounds.) Format your output with two decimal places.
Task 8:
The manager of a football stadium wants you to write a program that
calculates the total ticket sales after each game. There are four types of
ticketsbox, sideline, premium, and general admission. After each game,
data is stored in a file in the following form:
ticketPrice numberOfTicketsSold
...

Sample data are shown below:


250 5750
100 28000
50 35750
25 18750

The first line indicates that the ticket price is $250 and that 5750 tickets were
sold at that price. Output the number of tickets sold and the total sale amount.
Format your output with two decimal places.

Task 9:
Interest on a credit cards unpaid balance is calculated using the average daily
balance. Suppose that netBalance is the balance shown in the bill, payment is
the payment made, d1 is the number of days in the billing cycle, and d2 is
the number of days payment is made before billing cycle. Then, the average
daily balance is:
averageDailyBalance netBalance _ d1 _ payment _ d2=d1
If the interest rate per month is, say, 0.0152, then the interest on the
unpaid balance is:
interest averageDailyBalance _ 0:0152
Write a program that accepts as input netBalance, payment, d1, d2, and
interest rate per month. The program outputs the interest. Format your
output to two decimal places.
Task 10:
Write the missing statements in the following program so that it prompts
the user to input two numbers. If one of the numbers is 0, the program
should output a message indicating that both numbers must be nonzero. If
the first number is greater than the second number, it outputs the first
number divided by the second number; if the first number is less than the
second number, it outputs the second number divided by the first number;
otherwise, it outputs the product of the numbers.
Task 11:
Write a program that prompts the user to input a number. The program
should then output the number and a message saying whether the number is
positive, negative, or zero.
Task 12:
Write a program that prompts the user to input three numbers. The program
should then output the numbers in ascending order.
Task 13:
Write a program that prompts the user to input an integer between 0 and 35. If
the number is less than or equal to 9, the program should output the number;
otherwise, it should output A for 10, B for 11, C for 12 . . . and Z for 35.
Task 14:
In a right triangle, the square of the length of one side is equal to the sum of
the squares of the lengths of the other two sides. Write a program that
prompts the user to enter the lengths of three sides of a triangle and then
outputs a message indicating whether the triangle is a right triangle.
Task 15:
A box of cookies can hold 24 cookies, and a container can hold 75 boxes
of cookies. Write a program that prompts the user to enter the total
number of cookies, the number of cookies in a box, and the number of
cookie boxes in a container. The program then outputs the number of
boxes and the number of containers to ship the cookies. Note that each
box must contain the specified number of cookies, and each container
must contain the specified number of boxes. If the last box of cookies
contains less than the number of specified cookies, you can discard it and
output the number of leftover cookies. Similarly, if the last container

contains less than the number of specified boxes, you can discard it and
output the number of leftover boxes.
Task 16:
The number of lines that can be printed on a paper depends on the paper size,
the point size of each character in a line, whether lines are double-spaced or
single-spaced, the top and bottom margin, and the left and right margins of
the paper. Assume that all characters are of the same point size, and all lines
are either single-spaced or double-spaced. Note that 1 inch = 72 points.
Moreover, assume that the lines are printed along the width of the paper. For
example, if the length of the paper is 11 inches and width is 8.5 inches, then
the maximum length of a line is 8.5 inches. Write a program that calculates
the number of characters in a line and the number of lines that can be printed
on a paper based on the following input from the user:
a. The length and width, in inches, of the paper
b. The top, bottom, left, and right margins
c. The point size of a line
d. If the lines are double-spaced, then double the point size of each character
Task 17:
Write a program that calculates and prints the bill for a cellular telephone
company. The company offers two types of service: regular and premium.
Its rates vary, depending on the type of service. The rates are computed as
follows:
Regular service: $10.00 plus first 50 minutes are free. Charges for
over 50 minutes are $0.20 per minute.
Premium service: $25.00 plus:
a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free;
charges for more than 75 minutes are $0.10 per minute.
b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are
free; charges for more than 100 minutes are $0.05 per minute.
Your program should prompt the user to enter an account number, a
service code (type char), and the number of minutes the service was used.
A service code of r or R means regular service; a service code of p or P
means premium service. Treat any other character as an error. Your program
should output the account number, type of service, number of
minutes the telephone service was used, and the amount due from the user.
For the premium service, the customer may be using the service during the
day and the night. Therefore, to calculate the bill, you must ask the user to
input the number of minutes the service was used during the day and the
number of minutes the service was used during the night.
Task 18:
You have several pictures of different sizes that you would like to frame. A
local picture-framing store offers two types of framesregular and fancy.
The frames are available in white and can be ordered in any color the
customer desires. Suppose that each frame is 1 inch wide. The cost of
coloring the frame is $0.10 per inch. The cost of a regular frame is $0.15
per inch, and the cost of a fancy frame is $0.25 per inch. The cost of putting
a cardboard paper behind the picture is $0.02 per square inch, and the cost
of putting glass on top of the picture is $0.07 per square inch. The customer
can also choose to put crowns on the corners, which costs $0.35 per crown.
Write a program that prompts the user to input the following information

and then output the cost of framing the picture:


a. The length and width, in inches, of the picture
b. The type of the frame
c. Customers choice of color to color the frame
d. If the user wants to put the crowns, then the number of crowns
Task 19:
Samantha and Vikas are looking to buy a house in a new development.
After looking at various models, the three models they like are colonial,
split-entry, and single-story. The builder gave them the base price and the
finished area in square feet of the three models. They want to know the
model(s) with the least price per square foot. Write a program that accepts as
input the base price and the finished area in square feet of the three models.
The program outputs the model(s) with the least price per square foot.
Task 20:
One way to determine how healthy a person is by measuring the body fat
of the person. The formulas to determine the body fat for female and male
are as follows:
Body fat formula for women:
A1 = (body weight _ 0.732) + 8.987
A2 = wrist measurement (at fullest point) / 3.140
A3 = waist measurement (at navel) _ 0.157
A4 = hip measurement (at fullest point) _ 0.249
A5 = forearm measurement (at fullest point) _ 0.434
B = A1 + A2 A3 A4 + A5
Body fat = body weight B
Body fat percentage = body fat _ 100 / body weight
Body fat formula for men:
A1 = (body weight _ 1.082) + 94.42
A2 = wrist measurement _ 4.15
B = A1 A2
Body fat = body weight B
Body fat percentage = body fat _ 100 / body weight
Write a program to calculate the body fat of a person.

S-ar putea să vă placă și