Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

The short-term, 0-24 hours, parking fee, F, at an international airport is given by the

following formula:

where int(h + 1) is the integer value of h + 1. For example, int(3.2) = 3, int(4.8) = 4. Write a
program that prompts the user to enter the number of hours a car is parked at the airport
and outputs the parking fee.

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.

Write a program to read the Richter magnitude value from the user and display the result
for the following conditions:

Write a program for Horizon Phones, a provider of cellular phone service. Prompt a user
for maximum monthly values for talk minutes used, text messages sent, and gigabytes of
data used, and then recommend the best plan for the customer’s needs. A customer
who needs fewer than 500 minutes of talk and no text or data should accept Plan A at
$49 per month. A customer who needs fewer than 500 minutes of talk and any text
messages should accept Plan B at $55 per month. A customer who needs 500 or more
minutes of talk and no data should accept either Plan C for up to 100 text messages at
$61 per month or Plan D for 100 text messages or more at $70 per month. A customer who
needs any data should accept Plan E for up to 3 gigabytes at $79 or Plan F for 3 gigabytes
or more at $87.
A babysitter charges $2.50 an hour until 9:00 PM when the rate drops to $1.75 an hour
(the children are in bed). Write a program that accepts a starting time and ending time
in hours and minutes and calculates the total babysitting bill. You may assume that the
starting and ending times are in a single 24-hour period. Partial hours should be
appropriately prorated.

A person is eligible to be a US senator if they are at least 30 years old and have been a
US citizen for at least 9 years. To be a US representative these numbers are 25 and 7,
respectively. Write a program that accepts a person's age and years of citizenship as
input and outputs their eligibility for the Senate and House.

The speeding ticket fine policy in Podunksville is $50 plus $5 for each mph over the limit
plus a penalty of $200 for any speed over 90 mph. Write a program that accepts a speed
limit and a clocked speed and either prints a message indicating the speed was legal or
prints the amount of the fine, if the speed is illegal.

#1 (Geometry) An acute angle is less than 90 degrees, an obtuse angle is greater than 90 degrees, and a right angle is equal to
90 degrees. Using this information, write a C++ program that accepts an angle, in degrees, and displays the type of angle
corresponding to the degrees entered.

$2 .(Data Processing) A student’s letter grade is calculated according to the following schedule:

Using this information, write a C++ program that accepts a student’s numerical grade, converts the numerical grade to an
equivalent letter grade, and displays the letter grade.

#3. (Data Processing) The grade level of undergraduate college students is typically determined according to the following
schedule:

#4. (Data Processing) Based on an automobile’s model year and weight, the state of New Jersey determines the weight class
and registration fee by using the following schedule:
Using this information, write a C++ program that accepts an automobile’s year and weight and determines and displays its weight
class and registration fee

#5. (Data Processing) a. Write a C++ program to compute and display a person’s weekly salary as determined by the following
conditions: If the hours worked are less than or equal to 40, the person receives $8.00 per hour; otherwise, the person receives
$320.00 plus $12.00 for each hour worked over 40 hours. The program should request the hours worked as input and display the
salary as output.

#6. (Data Processing) Write, execute, and verify a C++ program that accepts three numbers as input, and then sorts the three
numbers and displays them in ascending order, from lowest to highest. For example, if the input values are 7 5 1, the program
should display them in the numerical order 1 5 7.

#7. (Data Processing) A program uses a char variable named department and two double variables named salary and raise. The
department variable contains one of the following letters (entered in either uppercase or lowercase): A, B, C, or D. Employees in
departments A and B are receiving a 2% raise. Employees in department C are receiving a 1.5% raise, and employees in
department D are receiving a 3% raise. Write the C++ code to calculate the appropriate raise amount.

#8. (Data Processing) Karlton Learning wants a program that displays the amount of money a company owes for a seminar. The
fee per person is based on the number of people the company registers, as shown in Figure below. For example, if the company
registers seven people, then the total amount owed is $560. If the user enters a number that is less than or equal to zero, the
program should display an appropriate error message.

#9. (Data Processing) The owner of Harry’s Car Sales pays each salesperson a commission based on his or her monthly sales.
The sales ranges and corresponding commission rates are shown in figure below:
Write a C++ program that will compute and display the commission earned by a salesperson. Display the commission in fixed-
point notation with two decimal places.

#10. (Data Processing) Shopper Haven wants a program that displays the number of reward points a customer earns each month.
The reward points are based on the customer’s membership type and total monthly purchase amount, as shown in Figure below:

Write a C++ program that would compute and display a customer’s reward points.

#11. (Trigonometry) An angle is given as a positive real number of degrees. Angles from 0° to (but not including) 90° fall in the
first quadrant, 90° to 180° are in the second, 180° to 270° are in the third, and 270° to 360° are in the fourth quadrant. The series
of quadrants starts all over again at 360°. Write a program that reads the value of an angle, prints out the angle, and the quadrant
it falls in.

#12. (Data Processing) An admission charge for The Little Rep Theater varies according to the age of the person. Compute and
print the ticket charge given the age of the person. The charges are as follows:
a. Over 55: $10.00
b. 21–54: $15.00
c. 13–20: $10.00
d. 3–12: $5.00
e. Under 3: Free

#13. (General Mathematics) Write a program that asks the user to enter a number within the range of 1 through 10. It should
display the Roman numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10.

#14. (Data Processing) The date June 10, 1960, is special because when we write it in the following format, the month times the
day equals the year 6/10/60. Write a program that asks the user to enter a month (in numeric form), a day, and a two digit year.
The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying
the date is magic. Otherwise, it should display a message saying the date is not magic.

#15. (Data Processing) A bank charges $10 per month plus the following check fees for a commercial checking account:
$.10 each for fewer than 20 checks
$.08 each for 20–39 checks
$.06 each for 40–59 checks
$.04 each for 60 or more checks
Write a program that asks for the number of checks written during the past month, then computes and displays the bank’s fees for
the month. Input Validation: Do not accept a negative value for the number of checks written.

#16. (Data Processing) Write a program that prompts the user to enter his annual gross income. The program should compute
and displays his total tax due based on the following table:
INCOME RANGE TAX DUE
income <=2, 500 0% of income
2, 500 < income <= 5, 000 1% of income
5,000 < income <=10, 000 25 + 3% of excess over 5, 000
10,000 < income <=20,000 175 + 7% of excess over 10,000
20,000 < income <=40,000 875 + 11% of excess over 20,000
40,000 < income <=60,000 3,075 + 15% of excess over 40,000
60,000 < income <= 100,000 6,075 + 19% of excess over 60,000
100,000 < income <=250,000 13,675 +24% of excess over 100,000
250,000 < income <=500,000 49,675+29% of excess over 250,000
income > 500,000 122,175+35% of excess over 500,000

#17. (Geometry) Write a menu driven program, in which a user enters the length of a line (unit of measurement will be of your
choice) and then is prompted to choose from the following options: 1. Area of Square, 2. Area of a Circle, 3. Volume of a Sphere,
4. Volume of a cylinder, 5. exit. If a user enters the Area of circle, the Volume of the sphere should also be shown. If the volume of
sphere is greater than 100, it should say, ”small sphere” otherwise, “big sphere”. If the volume of cylinder is less than 20, it should
say, “glass”. If its length is greater than 20 and less than 100, it should say, ”a jug” otherwise, a tank.

#18. (Data Processing ) A military academy accepts candidates according to the following height and weight requirements.

Write a program that accepts as input the gender, height and weight of a candidate. Check to see if the candidate meets the height
requirements and store the result in variable called heightOk. Next check the weight requirements and store the result in a variable
called weightOk. Using these results, determine whether the candidate was accepted, rejected for height only, rejected for weight
only or rejected for both height and weight. Output an appropriate message for each possible outcome.

#20. (Data Processing) Write a program which gives a menu to the user to select one from two choices.
Z to find your Zodiac Sign
X to exit the program
For example:
The program mainly helps user to find his/her zodiac sign (e.g. Virgo, Capricorn and so on). So if user wishes to continue then the
program should get date of birth as input and give the user an information about his/her zodiac sign. The program should not
terminate unless user wishes to.
#21. the Cartesian plane using the function named input_xy() and prints a corresponding message using
the function named location() that determines whether an axis on which the point lies or the quadrant in
which it is found.
Sample Output:
Enter coordinate for x : 0
Enter coordinate for y : 0
Your point (0,0) is located at the ORIGIN.

#22. Write a program that gives a discount of 100 pesos to a customer if the shirt bought is XL and the price is
greater than 500 pesos; a discount of 50 pesos if the shirt bought is L and the price is greater than 400.

Program that will compute the discount of the purchased Shirt…

Shirt’s Size (XL, L, S, M) :> L

Shirt’s Prize :> 780

Discount is: 50.00

Total Prize : 730.00

#23. The Violet mobile phone company charges 20.00 a month for it’s talk 22 tariff. The customer is charged 0.40 for
each call minute over the monthly allowance of the free 22 minutes. The Violet mobile phone company logs the total
number of minutes calls you have made since you were first connected and calculates your bill by subtracting last
months total call minutes from this months. Some typical bills are shown:

Old reading New reading Call minutes used Bill

345 375 30 23.20


234 246 12 20

567 589 22 £20

Create a program that will allow the company to enter the old reading and new reading and then calculate and display
the bill.

#24. Al's Last Chance Gas station sits on Route 190 on the edge of Death Valley. There is no other gas station for 200
miles. You are to write a program to help drivers decide if they need gas. The program asks for:
 The capacity of the gas tank, in gallons.
 The indication of the gas gauge in percent (full= 100, three quarters full = 75, and so on).
 The miles per gallon of the car.
The program then writes out "Get Gas" or "Safe to Proceed" depending on if the car can cross the 200 miles with the
gas remaining in the tank.

Tank capacity:
12
Gage reading:
50
Miles per gallon:
30
Get Gas!

#25. For this year Mega Sale Carnival, SOGO has announced the following discounts on purchase of items
based on department:

Purchase amount Department/Discount


Children Ladies Men
Department Department Department

0 – 100 2% 2.5% 5%
101 – 200 5% 7.5% 10.0%
201 – 300 7.5% 10.0% 12.5%
Above 300 10.0% 12.5% 15.0%

Write a program to compute the discount and net amount for a customer. Sample output:

Enter department (C – Children, L – Ladies, M – Men): W


Invalid!
Enter department (C – Children, L – Ladies, M – Men): O
Enter user purchase amount: 120.00

This user will get 5% discount.


Discount amount: Php 6.00
Net amount to pay: Php 114.00
#26. Write a program that accepts the first name of a sales person and their total sales for the month. Sales
commissions are calculated as follows:

Monthly Sales Commission Rate


1.00 - 1000.00 2%
1001.00 - 5000.00 5%
Over 5000.00 10%

Sample Run:
Sales Associate: Harry Hardsell
Monthly Sales: 6500.00
Commission Due: 650.00

#27. Write a program called TwelveDays. Construct a program that prints one of the gifts of the song "The Twelve
Days of Christmas". The program should input the user’s choice of day (1-12) and display the corresponding gift. If the
user entered any number besides the required it should prompt an appropriate error message. Remember the following
gifts are part of the “Twelve Days of Christmas”:

A partridge in a pear tree

Two turtle doves


Three French hens
Four calling birds
Five gold rings
Six geese a-laying
Seven swans a-swimming
Eight maids a-milking
Nine ladies dancing
Ten lords a-leaping'
Eleven pipers piping
Twelve drummers drumming

#28. Write a program that displays a suggested activity based on the outdoor temperature (in Fahrenheit)
and whether or not it is raining/snowing. Use the following table for suggested activities. Show both with
nested loops and with logical operators.

Temperature Raining/Snowing Activity


>=80 no beach volleyball
>=80 yes movie
<80 and >=32 no running
<80 and >=32 yes racquetball
<32 no ice fishing
<32 yes skiing
#29. Suppose you are an amusement park ride operator. Rides often come with restrictions on who can and cannot
ride, usually based on height and weight. Consider the following algorithm which decides ridership:

 If the height of the individual is less than or equal to 54 inches or the weight of the individual is less than 60
pounds, he or she cannot ride.

 If the height of the individual is greater than 54 inches and less than or equal to 84 inches, he or she can ride.

 If the height of the individual is greater than 84 inches or his/her weight is greater than 180 pounds, he or she
cannot ride.

Write a C++ program which prompts the user for his/her height and weight (both integers) and outputs a descriptive
message indicating their eligibility to ride.

#30. Write a program that will simulate a menu-driven calculator program. See sample run.

<<<< MAIN MENU >>>>

+ Addition * Multiplication E - Exit


- Subtraction / Division
Enter your choice: ___

The user needs to enter to float numbers after an operation options are entered (+, - , *, /) . If the user typed any
other character besides the required, the program will display an appropriate error message.

You might also like