C Programming

CONDITIONAL (SELECTION) STATEMENTS PRACTICAL QUESTIONS

1

You have been tasked with writing a program that asks the user to input 1, 2, 3, or 4 to indicate the weather condition and then instructs the user on what to do.

1 - Raining

2 - Sunny

3 - Cloudy

4 - Snowing

When it is raining, the user should take an umbrella or wear a raincoat.

When it is sunny, the user should wear sunglasses and apply sunscreen.

When it is cloudy, the user should carry a light jacket.

When it is snowing, the user should wear warm clothing and boots.

If the user enters an invalid option, the program should display "Invalid option. Please enter 1, 2, 3, or 4."

Follow the software development process by answering the following questions:

(a)

Write an algorithm for the program.

(b)

Draw a flowchart for the algorithm

(c)

Write a pseudocode for the algorithm

(d)

Implement the program

2

You have been tasked with writing a program to motivate video game players based on their scores.

When the score is 100, you should display a message saying "Congratulations! You've achieved a perfect score!"

When the score is 80 or more, you should display a message saying "Great job! You're doing well!"

When the score is 50 or more, you should display a message saying "Good Try! More room for improvement!"

When the score is less than 50, you should display a message saying "Keep practicing! You can do better!"

The user will input their score and receive a motivational message based on their performance.

If the user enters an invalid score, the program should display "Invalid score. Please enter a score between 0 and 100."

Follow the software development process by answering the following questions:

(a)

Write an algorithm to solve this problem.

(b)

Draw a flowchart to represent the algorithm.

(c)

Write a pseudocode to represent the algorithm.

(d)

Implement the program.

3

You've been tasked with writing a program to help kids practice traffic light safety.

1 - Red Light

2 - Yellow Light

3 - Green Light

When the light is red, display the message "Stop."

When the light is yellow, display the message "Prepare to stop."

When the light is green, display the message "Proceed."

If the user enters an invalid option, the program should display "Invalid option. Please enter 1, 2, or 3."

Follow the software development process by answering the following questions:

(a)

Write an algorithm for the program.

(b)

Draw a flowchart for the algorithm

(c)

Write a pseudocode for the algorithm

(d)

Implement the program

4

You've been tasked with writing a program that gives out snacks based on a button code.

1 - Dispensing Chocolate.

2 - Dispensing Chips.

3 - Dispensing Juice

When 1 is pressed, display the message "Here is your chocolate!"

When 2 is pressed, display the message "Here is your chips!"

When 3 is pressed, display the message "Here is your juice!"

If the user enters an invalid option, the program should display "Invalid option. Please enter 1, 2, or 3."

Follow the software development process by answering the following questions:

(a)

Write an algorithm for the program.

(b)

Draw a flowchart for the algorithm

(c)

Write a pseudocode for the algorithm

(d)

Implement the program