0% found this document useful (0 votes)
5 views

Problem Solving

The document outlines various problem-solving scenarios involving calculations for water bills, ticket charges, paper costs, hotel pricing, temperature alerts, sales discounts, loan repayment, palindrome checking, and camp attendee age averages. Each scenario includes a structured approach with initialization, input, conditional logic, and output steps. The solutions are designed to be implemented algorithmically for practical applications.

Uploaded by

talhazc013
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Problem Solving

The document outlines various problem-solving scenarios involving calculations for water bills, ticket charges, paper costs, hotel pricing, temperature alerts, sales discounts, loan repayment, palindrome checking, and camp attendee age averages. Each scenario includes a structured approach with initialization, input, conditional logic, and output steps. The solutions are designed to be implemented algorithmically for practical applications.

Uploaded by

talhazc013
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

1.

Complete the seven problem-solving steps to calculate the water bill given the cubic feet
of water used for Eureka Water Company, which charges the homeowner one of the
following: a. A flat rate of $15.00 for usage up to and including 1000 cubic feet. b. $0.0175
per cubic foot for usage over 1000 cubic feet and up to and including 2000 cubic feet. c.
$0.02 per cubic foot for usage over 2000 cubic feet and up to and including 3000 cubic feet.
1. Start
2. Initialize variables:
- cubic_feet_used
- flat_rate = 15.00
- rate_1 = 0.0175
- rate_2 = 0.02
- bill = 0
3. Input cubic_feet_used
4. If cubic_feet_used <= 1000, then
bill = flat_rate
Else if cubic_feet_used > 1000 and cubic_feet_used <= 2000, then
bill = flat_rate + (cubic_feet_used - 1000) * rate_1
Else if cubic_feet_used > 2000 and cubic_feet_used <= 3000, then
bill = flat_rate + (1000 * rate_1) + ((cubic_feet_used - 2000) * rate_2)
Else
Display "Usage over 3000 cubic feet is not supported"
5. Output bill
6. End

2. A company that issues check-cashing cards uses an algorithm to create card numbers.
The algorithm adds the digits of a four-digit number, and then adds a fifth digit of 0 or 1
to make the sum of the digits even. The last digit in the number is called the check digit.
Complete the seven problem-solving steps to develop a solution that accepts a four-digit
number into one variable, adds the check digit, and prints the original number and the new
number. Test your flowchart with the following data: Original (47371) and 4631 (46310).
1. Start
2. Input a four-digit number into variable "original_number"
3. Set "sum_of_digits" to 0
4. Set "check_digit" to 0
5. Split "original_number" into individual digits
6. Add each digit to "sum_of_digits"
7. If "sum_of_digits" is even, set "check_digit" to 0, otherwise set it to 1
8. Concatenate "original_number" and "check_digit" to form the new number
"new_number"
9. Print "original_number" and "new_number"
10. End
3. An admission charge for The Little Rep Theater varies according to the age of the person.
Develop a solution to 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
1. Start

2. Read age of the person

3. If age > 55 then


Print "Ticket charge: $10.00"
Else if age >= 21 and age <= 54 then
Print "Ticket charge: $15.00"
Else if age >= 13 and age <= 20 then
Print "Ticket charge: $10.00"
Else if age >= 3 and age <= 12 then
Print "Ticket charge: $5.00"
Else
Print "Ticket charge: Free"
Endif

4. End

4. A customer needs a specific amount of paper. The charges on the paper are $0.10 for
single sheets, $0.055 for amounts in multiples of 100 sheets, $0.04 in multiples of 500
sheets, and $0.03 in multiples of 1000 sheets. Develop a solution to calculate the type and
number of package(s) for the least amount of money the customer should buy, given the
minimum amount of sheets the customer needs. For example, if the customer needs 380
sheets, the amount she would pay when buying in multiples of 100 would be $22.00.
However, if the customer bought 500 sheets, the cost would be $20.00. It would be cost
effective for the customer to buy a package of 500 sheets
1. Start

2. Input the number of sheets needed (N)

3. Initialize variables:
total_cost = 0
package_count_1000 = 0
package_count_500 = 0
package_count_100 = 0
remainder = N
4. Calculate the number of packages needed for 1000 sheets:
package_count_1000 = N / 1000
remainder = N % 1000
total_cost += package_count_1000 * 0.03

5. Calculate the number of packages needed for 500 sheets:


package_count_500 = remainder / 500
remainder = remainder % 500
total_cost += package_count_500 * 0.04

6. Calculate the number of packages needed for 100 sheets:


package_count_100 = remainder / 100
remainder = remainder % 100
total_cost += package_count_100 * 0.055

7. Calculate the cost for remaining single sheets:


total_cost += remainder * 0.10

8. Output the total cost and the breakdown of packages:


Print "Total Cost: $" + total_cost
Print "Packages of 1000 sheets: " + package_count_1000
Print "Packages of 500 sheets: " + package_count_500
Print "Packages of 100 sheets: " + package_count_100
Print "Remaining single sheets: " + remainder

9. End

5. A hotel has a pricing policy as follows: a. 2 people: $85 b. 3 people: $90 c. 4 people: $95
d. Additional people: $6 per person If the customer is staying on company business, there
is a 20% discount. If the customer is over 60 years of age, there is a 15% discount. A
customer does not receive both discounts. Given the above data, print the cost of the room.
1. Start

2. Input number of people staying (num_people)


3. Input whether the customer is on company business (is_business) // True or False
4. Input customer's age (customer_age)

5. Set base_price = 0
6. Set discount = 0

7. If num_people == 2:
Set base_price = $85
Else if num_people == 3:
Set base_price = $90
Else if num_people == 4:
Set base_price = $95
Else:
Set base_price = $95 + ($6 * (num_people - 4))

8. If is_business:
Set discount = 0.20
Else if customer_age > 60:
Set discount = 0.15

9. If discount > 0:
Set total_price = base_price - (base_price * discount)
Else:
Set total_price = base_price

10. Print "The cost of the room is $" + total_price

11. End

6. A manufacturer would like to have a device for a car that will turn on a light when the
temperature is between 34 and 40 degrees Fahrenheit (F) and sound a warning signal when
the outside temperature is 34 degrees F or below. The light and the sound are never going
simultaneously. Write a solution to this problem.
1. Start

2. Initialize variables:
- temperature
- light_status = OFF
- sound_status = OFF

3. Repeat:
a. Read the temperature from the sensor.

b. If temperature <= 34:


i. Set sound_status = ON
ii. Set light_status = OFF
c. Else if temperature >= 34 and temperature <= 40:
i. Set sound_status = OFF
ii. Set light_status = ON
d. Else:
i. Set sound_status = OFF
ii. Set light_status = OFF

4. End loop

5. Display the status of the light and sound.

6. End

7. The Last Stop Boutique is having a five-day sale. Each day, starting on Monday, the price
will drop 10% of the previous day’s price. For example, if the original price of a product is
$20.00, the sale price on Monday would be $18.00 (10% less than the original price). On
Tuesday the sale price would be $16.20 (10% less than Monday). On Wednesday the sale
price would be $14.58; on Thursday the sale price would be $13.12; and on Friday the sale
price would be $11.81. Develop a solution that will calculate the price of an item for each
of the five days, given the original price. Test the solution for an item costing $10.00.
1. Start
2. Input original_price
3. Set current_price = original_price
4. Set discount_rate = 0.10
5. For i = 1 to 5
6. Set current_price = current_price - (current_price * discount_rate)
7. Output "Day ", i, ": $", current_price
8. End for
9. End

8. Mary Smith, a student, has borrowed $3,000 to help pay her college expenses. After
setting up a budget, $85 was the maximum monthly payment she could afford to make on
the loan. Develop a solution to calculate and print the interest, the principal, and the
balance on the loan per month. Other information she would like to know is the number of
years and months it will take to pay the loan back and the total interest she will pay during
that period. The interest rate is 1% per month on the unpaid balance. Keep in mind these
formulas: payment = balance - interest interest normal = balance*interest rate new balance
= balance - payment .
1. Initialize variables:
- loan_amount = 3000 (amount borrowed)
- monthly_payment = 85 (maximum monthly payment)
- interest_rate = 0.01 (1% interest rate per month)
- balance = loan_amount (initial loan balance)
- total_interest = 0
- months = 0
2. While balance > 0:
3. Increment months by 1

4. Calculate interest for the current month:


5. interest = balance * interest_rate

6. Calculate principal payment for the current month:


7. principal = monthly_payment - interest

8. If principal > balance:


9. Set principal to balance

10. Calculate new balance after payment:


11. balance = balance - principal

12. Update total interest paid:


13. total_interest = total_interest + interest

14. Print current month's information:


15. Print "Month:", months
16. Print "Principal Payment:", principal
17. Print "Interest Payment:", interest
18. Print "Remaining Balance:", balance

19. Calculate total years and months to pay o the loan:


20. total_months = months
21. years = total_months // 12
22. months = total_months % 12

23. Print total years and months to pay o the loan:


24. Print "Total time to pay o the loan:", years, "years and", months, "months."

25. Print total interest paid:


26. Print "Total interest paid:", total_interest

8. Write a solution to tell the user whether a number is a palindrome. (A palindrome is a


number that is the same written both forward and backward, such as 81318.) .
1. Start
2. Initialize variables:
num = input number
reversed_num = 0
original_num = num
3. While num is greater than 0:
4. Digit = num mod 10
5. reversed_num = (reversed_num * 10) + digit
6. num = num / 10
7. If original_num is equal to reversed_num:
8. Print "Palindrome"
9. Else:
10. Print "Not Palindrome"
11. End

9. he counselor of a camp would like to know the average age of those attending a camp,
and who the oldest and the youngest are. The number of people attending a camp can
vary from 50 to 100..
1. Start
2. Initialize variables: total_age = 0, count = 0, oldest_age = 0, youngest_age = infinity
3. Input the number of attendees (n) // Assuming it's within the range of 50 to 100
4. Repeat n times:
a. Input age of attendee
b. Add age to total_age
c. Increment count
d. If age > oldest_age, set oldest_age = age
e. If age < youngest_age, set youngest_age = age
5. Calculate average_age = total_age / count
6. Display average_age, oldest_age, and youngest_age
7. End

You might also like