Top Banner
EXERCISE IN CLASS CHAPTER 2
15

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.

Jan 03, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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.

EXERCISE IN CLASS

CHAPTER 2

Page 2: 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.

PART 1

SEQUENCE

Page 3: 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.

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.

Page 4: 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.

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.

Page 5: 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.

PART 1

SELECTION

Page 6: 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.

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.

Page 7: 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.

SCENARIO 2Write 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 RM20.00. Display total price to user.

Page 8: 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.

SCENARIO 3Modify question in scenario 1. Program will displays status based on below condition:• weight >100kg, status=“Obese”• weight < 30kg, status= “Underweight”• others, status = “Normal”

Page 9: 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.

SCENARIO 4Ask 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 200.00• T Twin Sharing 170.00• S Single 120.00Display details of info to user.

Page 10: 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.

PART 1

REPETITION

Page 11: 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.

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: 5 10 15 20 25 30 35 40 45 50

SCENARIO 1

Page 12: 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.

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

Page 13: 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.

SCENARIO 3Create 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.

Page 14: 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.

SCENARIO 4Write a pseudo code for below program:Given, series of values : 1 2 3 4 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”

Page 15: 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.

THAT’S ALL FOR TODAY……

SEE YA NEXT CLASS