Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views2 pages

If Statements Practice

The document outlines six programming problems that involve basic conditional logic. These include setting an alarm based on the day of the week, controlling air conditioning based on temperature, determining movie ticket discounts based on age, calculating bus fare based on distance, checking if a number is positive, negative, or zero, and applying a discount to a bill over a certain amount. Each problem includes specific requirements and sample outputs for clarity.

Uploaded by

riambonanzaelmar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

If Statements Practice

The document outlines six programming problems that involve basic conditional logic. These include setting an alarm based on the day of the week, controlling air conditioning based on temperature, determining movie ticket discounts based on age, calculating bus fare based on distance, checking if a number is positive, negative, or zero, and applying a discount to a bill over a certain amount. Each problem includes specific requirements and sample outputs for clarity.

Uploaded by

riambonanzaelmar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

FOR PRACTICE ONLY

1. Alarm Clock

You have an alarm set for 7 AM every day, but on weekends you want to sleep in and set the
alarm for 9 AM instead.

Problem:
Write a program that checks if it's a weekend (Saturday or Sunday) and adjusts the alarm
accordingly.

Requirements:

 If the day is "Saturday" or "Sunday," set the alarm for 9 AM.


 Otherwise, set the alarm for 7 AM.

SAMPLE OUTPUT:

Enter Day: Saturday


Set alarm for 9 AM

Enter Day: Tuesday


Set alarm for 7 AM

2. Temperature Check

You are using a smart thermostat that adjusts the air conditioning based on the current
temperature.

Problem:
Create a program that turns on the air conditioning if the temperature is above 25°C.

Requirements:

 If the temperature is above 25°C, turn on the air conditioning.


 Otherwise, keep it off.

SAMPLE OUTPUT

Enter temperature: 30
Turn on Air Conditioning

Enter temperature: 22
Keep Air Conditioning Off

3. Movie Ticket Discount

A movie theater offers a discount for children under 12 years old and seniors 60 years or older.

Problem:
Write a program that determines whether a person qualifies for a discounted movie ticket.

Requirements:

 If the age is less than 12 or greater than or equal to 60, they receive a discount.
 Otherwise, they pay the full price.
4. Bus Fare Based on Distance

Bus fare is calculated based on the distance traveled. The fare structure is as follows:

 For trips less than 5 km: $2


 For trips between 5 km and 15 km: $5
 For trips over 15 km: $10

Problem:
Write a program that determines the fare based on the distance traveled.

Requirements:

 If the distance is less than 5 km, the fare is $2.


 If the distance is between 5 km and 15 km, the fare is $5.
 If the distance is over 15 km, the fare is $10.

SAMPLE OUTPUT:

Enter Distance: 18
Fare is $10

Enter Distance: 7
Fare is $5

5. Positive, Negative, or Zero

Problem:
Create a program that checks if a number is positive, negative, or zero.

Requirements:

 If the number is greater than zero, it’s positive.


 If it’s less than zero, it’s negative.
 If it equals zero, print "zero."

6. Discount Calculator

Scenario: A store offers a 10% discount if the total bill exceeds $100.

Problem: Write a program that asks the user to enter the total bill amount. If the bill is more than
$100, apply the discount and display the final amount. Otherwise, display the original amount.

SAMPLE OUTPUT:

Enter your total bill: 150


The final amount after 10% discount is $135.0

Enter your total bill: 75


The total amount is $75

You might also like