EXERCISE IN CLASS CHAPTER 2
PART 1 SEQUENCE
SCENARIO 1 Write an algorithm for a C program, that prompts user to enter total number of umbrellas he/she wants to buy. Price of one umbrella is RM3.00. This program will calculates and displays total price of these umbrellas to user.
SCENARIO 2 Write an algorithm for a program that capable to calculate and displays sum of three numbers. All numbers will be entered by user.
PART 1 SELECTION
SCENARIO 1 Write an algorithm for below scenario: Ask user to enter weight. Program will only displays status “You’re obese” if the weight is more than 100kg.
SCENARIO 2 Write an algorithm for a program that will calculate discount, based on the quantity of book purchased. 10% discount will be given if customer pays for more than 50 books, where cost of each book is RM Display total price to user.
SCENARIO 3 Modify question in scenario 1. Program will displays status based on below condition: weight >100kg, status=“Obese” weight < 30kg, status= “Underweight” others, status = “Normal”
SCENARIO 4 Ask the user to enter room code and number of days they want to stay. Identify the room type and room price based on the table given below: Code Type Price (RM) D Deluxe T Twin Sharing S Single Display details of info to user.
PART 1 REPETITION
Write an algorithm for below scenario: Ask user to enter an alphabet. Display the alphabet up to 5 times. Using while loop, display the sum of values from 1 to 10. Display multiplication table for no 5 up to 10 values. Sample output: SCENARIO 1
Prompt user to enter one word. Program will displays the word according to how many times he/she wants the word to be displayed. SCENARIO 2
SCENARIO 3 Create a system that will accept and displays even numbers. The system will only stop when the user enters an odd number. Develop a program to display a symbol up to 5 times. Ask user to enter “yes” keyword to run the program and a symbol for input. System will only stop if user enters other than “yes” keyword.
SCENARIO 4 Write a pseudo code for below program: Given, series of values : and 5. Write a program that will displays values from highest to lowest or vice versa with regards to selection entered by user: enter 1 : to display highest to lowest enter 2 : to display lowest to highest others : displays “Wrong input”
THAT’S ALL FOR TODAY…… SEE YA NEXT CLASS