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.

Slides:



Advertisements
Similar presentations
Desk Checking. Desk checking is a manual (non computerised) technique for checking the logic of an algorithm. The person performing the desk check effectively.
Advertisements

Exercise (1).
Introduction to Flowcharting
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Using Flowcharts. Sample Flowchart (without text) 2.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
An Introduction to Programming with C++ Fifth Edition Chapter 5 The Selection Structure.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
PROBLEM SOLVING What should I wear today? Which sport should I do? Which cell phone is best for me? Which team is probably the winner? Will Euro be raised.
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
Chapter 2: Input, Processing, and Output
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
Chapter 1 Pseudocode & Flowcharts
Sw development1 Software Development 1.Define the problem (Analysis) 2.Plan the solution 3.Code 4.Test and debug 5.Maintain and Document.
REPETITION STRUCTURES. Topics Introduction to Repetition Structures The while Loop: a Condition- Controlled Loop The for Loop: a Count-Controlled Loop.
Chapter 2: Problem Solving
Chapter 2: Problem Solving
PYTHON PROGRAMMING Week 10 – Wednesday. TERMS – CHAPTER 1 Write down definitions for these terms:  Computation  Computability  Computing  Artificial.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Looping Exercises Deciding Which Loop to Use At this.
Looping While-continue.
1. Definition and General Structure 2. Small Example 1 3. Simplified Structure 4. Short Additional Examples 5. Full Example 2 6. Common Error The for loop.
Software Life Cycle What Requirements Gathering, Problem definition
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored.
Python Repetition. We use repetition to prevent typing the same code out many times and to make our code more efficient. FOR is used when you know how.
Problem : At Kiddy School, the teachers used the A, B,C for grading the students’ works. If the student get an A, then the teacher will print “Excellent”
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
1 Programming with MATLAB ผศ. ดร. อนันต์ ผลเพิ่ม Anan Phonphoem
Conditionals CS 103 February 16, Blast from the Past: C14 Dating Problem Statement: Calculate the age of a fossil from its C-14 radioactivity Problem.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Continue with conditional
© The McGraw-Hill Companies, 2006 Chapter 2 Selection.
CS 100 Introduction to Computing Seminar
Count and add list of numbers From user input and from file.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Computer Programming TCP1224 Chapter 5 The Selection Structure.
Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic nd Edition.
2. WRITING SIMPLE PROGRAMS Rocky K. C. Chang September 10, 2015 (Adapted from John Zelle’s slides)
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
Chapter 7 Problem Solving with Loops
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
CHAPTER 3 CONTROL STRUCTURES ( SELECTION ) I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
For loop. Exercise 1 Write a program to have the user input three (3) numbers: (f)rom, (t)o, and (i)ncrement. Count from f to t in increments of i, inclusive.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
Keywords: Range Trace table Testing List Index Activities: To create a trace table for a small piece of code using a set of data. Create a trace table.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CIS 115 All Exercises Devry University (Devry) For more course tutorials visit CIS 115 All Exercises Devry University.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
CIS 115 AID Peer Educator/cis115aid.com FOR MORE CLASSES VISIT
Problem solving Chapter 3
CIS 115 Slingshot Academy / Tutorialrank.com Tutorialrank.com For More Tutorials
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
COMBAT VEHICLE SERVICE AND REPAIR REPORT SYSTEM. Our country defense unit does have a lot of combat vehicle. These vehicles being used to protect our.
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Chapter 1 Introduction to Java
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Chapter 5: Control Structure
Topics Introduction to Repetition Structures
CIS 115 Possible Is Everything/snaptutorial.com
For Monday Read WebCT quiz 18.
Control Structure Senior Lecturer
Chapter 8 The Loops By: Mr. Baha Hanene.
For Wednesday No new reading No quiz.
Flowcharts and Pseudo Code
21 3 Variables Selection Functions Repetition Challenge 21
Desk Checking.
Continue with conditional
WJEC GCSE Computer Science
Presentation transcript:

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