c

© All Rights Reserved

219 tayangan

c

© All Rights Reserved

- Olevel Computer Science Notes (2210)
- A Levels Computing 9691 Revision Notes
- Pre-released Material for June 2015 Final
- Notes Logic Gate
- Robotics & Automation
- PA8-Solution_29428 (1)
- 9691-01 Revision Notes (Modified F451)
- A2 computer Science - Computer Networking Problems
- GenFam Algo and Meeting Notes
- Wireless, Distributed Modalities.pdf
- 2.Direct_Digital_Control.pptx
- Obesity
- Boys Chart
- ksde standard 9 artifact
- ctrendsunit6elderly
- Development
- BMI and Diabetes
- Chap8
- Maquinas de Estados
- o Level Computer Science

Anda di halaman 1dari 22

TempA0

TempB0

Weather

Pseudocode

Flow Chart

Output TempB

Output

Process

NonIterative

Formula/Value

Calculation

TempB (TempA-32)/1.8

is

TempB<20

?

Ye

s

Example:

TempA0

TempB0

Weather

Example:

DIM TempA As Integer=0

DIM TempB As Integer =0

DIM Weather As String=

Example:

READ TempA,

[Variable Name]=Console.ReadLine()

Example:

TempA=Console.ReadLine()

No

Pseudoco

de

Example:

PRINT TempB, BMI, Over weight

Message/Comment)

Example:

Console.WriteLine (TempB & BMI & Over

weight)

TempB (TempA-32)/1.8

TempB=(TempA-32)/1.8

{ statement 1 }

ELSE

{ statement 2 }

ENDIF

{ statement 1 }

ELSE

{ statement 2 }

ENDIF

Iterative

Example:

CountA

CountA+1

CountB

CountB+1

Formula/Val

ue

Calculation

Selection

Algorithm

Input TempA

Input

VB/VB.Net

IF Temp<20 THEN

CountA CountA+1

ELSE

CountB CountB+1

ENDIF

Totaling

Condition based

Loop

Example:

If Temp<20 Then

CountA=CountA+1

Else

CountB= CountB+1

End If

Counting

Extreme

Values

{ statement 1 }

Example:

IF TempB>Highest THEN Highest TempB

Example:

If TempB>Highest Then Highest = TempB

IF.THEN statement is written on a single

line.)

statement is written on a single line.)

No

Yes

is

TempB> Highest

?

Highest TempB

Ye

s

is

Weather=Foggy

?

Case expression list

Statements

Case Else

Else statement

End Select

No

FoggyFoggy+1

IF Weather =Cloudy THEN

CloudyCloudy+1

IF Weather =Rainy THEN

Rainy Rainy +1

Else

Sunny Sunny +1

ENDIF

CASE [Variable Name ] OF

expression : statement

expression : statement

expression : statement

OTHERWISE else statement

ENDCASE

Foggy

Foggy+1

Selection

Sunny

Sunny +1

Example:

CASE Weather OF

Foggy : FoggyFoggy+1

Cloudy: CloudyCloudy+1

Rainy : RainyRainy+1

OTHERWISE SunnySunny+1

ENDCASE

Example:

Module Module1

Sub Main()

DIM Weather as String

DIM Foggy as Integer=0

DIM Cloudy as Integer=0

DIM Rainy Yes

as Integer=0

DIM Sunny as Integer=0

Weather=Console.ReadLine()

is

Select Weather Weather=Cloudy

Case

"Foggy"

?

Cloudy

Foggy=Foggy+1

Cloudy+1

Case "Cloudy"

Cloudy=Cloudy+1

Case "Rainy"

Rainy=Rainy+1

Case Else

Yes

Sunny=Sunny+1

End Select

is

Console.WriteLine (Foggy)

Weather=Rainy

Console.WriteLine

(Cloudy)

?

Console.WriteLine

(Rainy)

Rainy

Console.WriteLine

(Sunny)

Rainy+1

End Sub

End Module

(You can try this code online at

http://ideone.com/EOBwlK,)

No

No

Counter could be

Count, X, etc.

Start

Count 0

Yes

Count=100

No

Output

"Hello World"

Count Count + 1

End

-------Things to do

-------within loop

---------------------NEXT

Things to do

-------outside the loop

--------------Example:

Print Hello World 100 times:

FOR Count=1 TO 100

PRINT Hello World

NEXT

Counter could be

Count, X, etc.

DIM Counter As Datatype

FOR Counter = Start TO End

-------Things to do within

-------loop

---------------------NEXT

Things to do outside

-------the loop

--------------Example:

Print Hello World 100 times:

Module Module1

Sub Main()

Dim Count As Integer

For Count= 1 To 100

Console.WriteLine("Hello World)

Next

End Sub

End Module

Start

Count 0

Input

Code

Yes

Code=9999

No

Print

"Hello World"

Input

Code

End

WHILE [Variable Name <> condition

DO

-------Things to do

-------within loop

---------------------READ [Variable Name]

ENDWHILE

Things to do

-------outside the loop

--------------Example:

Print Hello World till code 9999 was

entered:

READ Code

WHILE Code <> 9999

DO

PRINT Hello World

READ Code

ENDWHILE

While condition

[ statements ]

[ Continue While ]

[ statements ]

[ Exit While ]

[ statements ]

End While

Example:

Print Hello World till code 9999 was entered:

Module Module1

Sub Main()

Dim Code As Integer=0

Code=Console.ReadLine()

While Code<>9999

Console.WriteLine(Hello World)

Code=Console.ReadLine()

End While

End Sub

End Module

1) Start of Flowchart

Start

Count0

CountA0

and

initialized

CountB0

TempA0

TempB0

Total0

Avg0

Highest0

Lowest1000

3) Start of the

loop. Set loop exit condition i.e. Count=100 if you ha

Yes

is

Count=100

4) Input Command

No

AvgTotal/100

Input

TempA

Output

Avg, CountA, CountB Highest, Lowest

TempB (TempA-32)/1.8

End

Output

TempB

Total Total +TempB

12) Always Print Average, Counting Variables, and Extreme Values outside the loop.

No

Yes

CountA CountA+1

the form of a flowchart which

takes temperatures input in

Fahrenheit over a 100 day period

(once per day). Convert the

temperature in Celsius with the

help of following formula:

Temp (in Celsius)=(Temp

(in Fahrenheit) - 32)/1.8

and output temperature in

Celsius, also print:

(b) number of days when the

temperature was below 20C

and the number of days when

the temperature was 20C and

above.

(c) average temperature of 100

days.

(d) the highest and lowest

temperature recorded in these

100days.

is

TempB<20

?

CountB CountB+1

Yes

No

is

TempB>Highest

?

Highest TempB

Yes

No

Lowest TempB

is

TempB<Lowest

?

10) Increment the loop counter by 1 for the next iteration and

Count Count+1

Initialization

Start

([Variable]Initial Value)

Initialization Box

Yes

Loop exit

Condition Check

No

Input Value

Input [Variable]

Value Calculation

(TotalTotal+[Variabl

Counting based on co

Output Result

Totaling

data to find)

CountACountA+1)

Counting

Condition Check

Yes

No

find)

Increment the

counter by 1

Yes

Increment the

counter by 1

(IF [Variable]>Highes

Highest [Variable])

(IF [Variable]<Lowest

Lowest [Variable])

Next

Calculate Average

Increment the counter and return to loop exit condition

Calculate Percentage

Calculate Average

Output Average,

Counting, Extreme Values

End

(Per(CountA/Loop End V

Values

Start

Question:

Write an algorithm in the form of a

flowchart which takes temperatures

input in Fahrenheit over a 100 day

period (once per day). Convert the

temperature in Celsius with the help

of following formula:

Temp (in Celsius)=(Temp (in

Fahrenheit) - 32)/1.8

and output temperature in Celsius,

also print:

(b) number of days when the

temperature was below 20C and

the number of days when the

temperature was 20C and above.

(c) average temperature of 100

days.

(d) the highest and lowest

temperature recorded in these

100days.

Variables to be

used

Count

TempA

TempB

CountA

CountB

Total

Avg

Highest

Lowest

to Store/Count

No of iteration

Temp in Fahrenheit

Temp in Celsius

Number of days

temp was below 20

Number of days

temperature was 20

and above

Running sum of 100

days temperature

Average

temperature of

100days

Highest temperature

in 100 days

Lowest temperature

in 100 days

Yes

Count0

CountA0

CountB0

Total0

Avg0

Highest0

Lowest1000

Count0

Count=100

TempB0

CountA0

CountB0

TempA0

Total0

No

Input

TempA

Avg0

Highest0

Lowest1000

FOR Count 1 TO 100

Output

TempB

READ TempA

Total Total + TempB

Yes

TempB<20

No

TotalTotal+Tem

CountA CountA + 1

IF TempB < 20 T

CountB CountB + 1

CountA

Yes

TempB>Highest

ELSE

No

CountB

ENDIF

HighestTempB

IF TempB>Highe

Yes

TempB<Lowest

No

HighestTempB

IF TempB<Lowes

LowestTempB

Lowest TempB

NEXT

Count Count + 1

AvgTotal/100

Avg Total/100

Output

Avg, CountA, CountB, Highest, Lowest

End

Start

Num0

Count0

Num0

Count0

CountA0

Largest00

pseudocode or a flowchart,

which

inputs 50 positive

numbers

outputs how many of the

numbers were > 100

Outputs the value of the

largest (highest) number

input

Yes

CountA0

Largest0

FOR Count1 TO 50

READ Num

Count=50

IF Num>100 THE

No

CountACountA+1

Input

Num

IF Num>Largest

LargestNum

Yes

Num>100

No

NEXT

PRINT CountA, Largest

CountA CountA + 1

Yes

Num>Largest

No

Largest Num

Count Count + 1

End

1) Start of Flowchart

Start

Count0

CountA0

and

initialized

CountB0

TempA0

TempB0

Total0

Avg0

Highest0

Lowest1000

Day

3) Input Command

Initialization

Input Day,

Start

TempA

[Variable]Initial Value)

Input [Variable]

Initialization Box

4) Start

of the loop. Input

UseValue

input variable to set Output

loop exit

conditio

Calculated

Val

Yes

Yes

Loop exit

Condition Check

No

(TotalTotal+[Variabl

Day= Friday

Value

? Calculation

AvgTotal/Count

data to find)

Output

Result

Calculate Average

(Avg Total/Count)

CountACountA+1)

TempB (TempA-32)/1.8

Totaling

Output

Output

Avg, CountA, CountB Highest, Lowest

Counting based on co

No

End

Total Variable)

Output

Count 6)

Count

+1

(to calculate average)

find)

(IF [Variable]>Highes

Output

YesCounting ConditionNo

Check

TempB

Highest [Variable])

(IF [Variable]<Lowest

7) Add the

input value orIncrement

result the

of value calculated if averag

Increment the

counter variable by 1

counter variable by 1

Input [Variable]

Yes

Extreme

End

Lowest [Variable])

No

Value Check

Endwhile

Calculate Average

Count Count+1

Extreme

Yes

Calculate Percentage

(Per(CountA/Loop End V

Value Check

No

13) Always Print Average, Counting Variables, and Extreme Values outside the loop.

Output

Counting

9) Set the counting condition if tally is required

and Average,

increment

the

Values

No

Yes

CountA CountA+1

the form of a flowchart which

takes temperatures input in

Question: Write an algorithm in the

Fahrenheit on certain days (stop

form of a flowchart which takes

by Friday). Convert the

temperatures input in Fahrenheit on

temperature in Celsius with the

certain days (stop by Friday).

help of following formula:

Convert the temperature in Celsius

Temp (in Celsius)=(Temp

with the help of following formula:

(in Fahrenheit) - 32)/1.8

Temp (in Celsius)=(Temp (in

and output temperature in

Fahrenheit) - 32)/1.8

Celsius, also print:

and output temperature in Celsius,

(b) number of days when the

also print:

temperature was below 20C

(b) number of days when the

and the number of days when

temperature was below 20C and

the temperature was 20C and

the number of days when the

above.

temperature was 20C and above.

(c) average temperature of 100

(c) average temperature of 100

days.

days.

(d) the highest and lowest

(d) the highest and lowest

temperature recorded in these

temperature recorded in these

100days.

100days.

Variables to be

to Store/Count

is

Input Value

TempB<20

?

CountB CountB+1

Yes

No

is

TempB>Highest

?

Highest TempB

Yes

Lowest TempB

No

is

TempB<Lowest

?

Count0

CountA0

CountB0

TempA0

TempB0

Total0

Avg0

Highest0

Lowest1000

Highest/Lowest,

Tallest/Shortest,

Day

READ TempA, Day

WHILE DAY<>Friday

Do

TempB (TempAPRINT TempB

TotalTotal+Tem

CountCount+1

IF TempA < 20

THEN

ELSEre

11) Input command for next iteration before

Input Day,

TempA

ENDIF

IF TempB>Highe

HighestTempB

IF TempB<Lowes

LowestTempB

READ TempA, Da

ENDWHILE

AvgTotal/Count

PRINT Avg, CountA, Coun

used

Count

Day

TempA

TempB

CountA

CountB

Total

Avg

Highest

Lowest

No of days

Day of week

Temp in Fahrenheit

Temp in Celsius

Number of days

temp was below 20

Number of days

temperature was 20

and above

Running sum of 100

days temperature

Average

temperature of

100days

Highest temperature

in 100 days

Lowest temperature

in 100 days

Start

Count0

CountA0

CountB0

Total0

Avg0

Highest0

Lowest1000

Day

Input

TempA, Day

Yes

Day="Friday"

No

Avg Total/100

Output

TempB

Output

Count Count + 1

End

Yes

TempB<20

CountACountA + 1

No

CountBCountB + 1

Yes TempB>HighestNo

Highest TempB

Yes TempB<Lowest No

LowestTempB

Input

Day, TempA"

Num0

Start

pseudocode or a flowchart,

which

inputs a set of positive

numbers (which end

with -1)

outputs how many of the

numbers were > 100

outputs the value of the

largest (highest) number

input

CountA0

Largest00

Num0

CountA0

Largest0

READ Num

WHILE Num<> -1

Input

Num

Yes

Do

IF Num>100 THEN C

IF Num>Largest THE

Num= - 1

READ Num

No

Yes

Num>100

ENDWHILE

No

CountA CountA + 1

Yes

Num>Largest

No

Largest Num

Input

Num

End

pseudocode or a flowchart,

which

inputs a set of positive

numbers (which end

with -1)

outputs the average

(mean) value of the

input numbers

outputs the value of the

largest (highest) number

input

Start

Num0

Total0

Count0

Largest00

Avg0

Num0

Count0

Input

Num

Total0

Avg0

Yes

Num= - 1

Largest0

READ Num

No

WHILE Num<> -1

TotalTotal + Num

Do

TotalTotal+Num

CountCount + 1

Yes

Num>Largest

CountCount+1

No

IF Num>Largest THE

READ Num

ENDWHILE

AvgTotal/Count

Largest Num

Input

Num

End

Practice Questions:

(1) Daniel lives in Italy and travels to Mexico, India and New Zealand. The times differences are:

Country

Hours

Minutes

Mexico

-7

0

India

+4

+30

New Zealand

+11

0

Thus, if it is 10:15 in Italy it will be 14:45 in India.

(a) Write an algorithm, using pseudocode or otherwise, which:

Inputs the name of the country

Inputs the time in Italy in hours (H) and minutes (M)

Calculates the time in the country input using the data from the table

Outputs the country and the time in hours and minutes

(2) As part of an experiment, a school measured the heights (in metres) of all its 500 students.

Write an algorithm, using pseudocode, which inputs the heights of all 500 students and outputs the height of the tallest person and the shortest person in the school.

(3) A geography class decide to measure daily temperatures and hours of sunshine per day over a 12 month period (365 days)

Write an algorithm, using pseudocode, which inputs the temperatures and hours of sunshine for all 365 days, and finally outputs the average (mean) temperature for

the year and the average (mean) number of hours per day over the year.

(4) A small shop sells 280 different items. Each item is identified by a 3 digit code. All items that start with a zero (0) are cards, all items that start with a one (1) are

sweets, all items that start with a two (2) are stationery and all items that start with a three (3) are toys.

Write an algorithm, using pseudocode, which inputs the 3 digit code for all 280 items and outputs the number of cards, sweets, stationery and toys.

(5) A company are carrying out a survey by observing traffic at a road junction. Each time a car, bus, lorry or other vehicle passed by the road junction it was noted

down.

10 000 vehicles were counted during the survey.

Write an algorithm, using pseudocode, which:

inputs all 10000 responses

outputs the number of cars, buses and lorries that passed by the junction during the survey

outputs the number of vehicles that werent cars, buses or lorries during the survey

(6) Speed cameras read the time a vehicle passes a point (A) on the road and then reads the time it passes a second point (B) on the same road (points A and B are

100 metres apart). The speed of the vehicle is calculated using:

The maximum allowed speed is 100 kilometres per hour. 500 vehicles were monitored using these cameras over a 1 hour period.

Write

inputs the start time and end time for the 500 vehicles that were monitored

calculate the speed for each vehicle using the formula above

outputs the speed for each vehicle and also a message if the speed exceeded 100 km/hour

output the highest speed of all the 500 vehicles monitored

May/June 2006

16 (a) A formula for calculating the body mass index (BMI) is:

Calculate the BMI for a person whose weight is 80kg and height is 2 metres.

[1]

(b) Using pseudocode or otherwise, write an algorithm that will input the ID, weight (kg) and height (m) of 30 students, calculate their body mass index

(BMI) and output their ID, BMI and a comment as follows:

A BMI greater than 25 will get the comment OVER WEIGHT, a BMI between 25 and 19 (inclusive) will get NORMAL and a BMI less than 19 will get

UNDER WEIGHT.

[6]

20 Temperatures (C) are being collected in an experiment every hour over a 200 hour period. Write an algorithm, using pseudocode or otherwise, which

inputs each temperature and outputs

how many of the temperatures were above 20C

how many of the temperatures were below 10C

the lowest temperature that was input

[5]

May/June 2007

19 A company has 5000 CDs, DVDs, videos and books in stock. Each item has a unique 5-digit code with the first digit identifying the type of item, i.e.

1 = CD

2 = DVD

3 = video

4 = book

For example, for the code 15642 the 1 identifies that it is a CD, and for the code 30055 the 3 identifies that it is a video.

Write

Inputs the codes for all 5000 items

Validates the input code

Calculates how many CDs, DVDs, videos and books are in stock

Outputs the four totals.

Oct/Nov 2007

16 (a) Fuel economy for a car is found using the formula:

[5]

[1]

(b) The Fuel Economy for 1000 cars is to be calculated using the formula in Question 16(a).

Write an algorithm, using pseudocode or otherwise, which inputs the Distance Travelled (km) and the Fuel Used (litres) for 1000 cars. The Fuel Economy

for each car is then calculated and the following outputs produced:

Fuel Economy for each car

average (mean) Fuel Economy for all of the cars input

the best Fuel Economy (i.e. highest value)

the worst Fuel Economy (i.e. lowest value)

[6]

May/June 2008

19 Customers can withdraw cash from an Automatic Teller Machine (ATM).

withdrawal is refused if amount entered > current balance

withdrawal is refused if amount entered > daily limit

if current balance < $100, then a charge of 2% is made

if current balance $100, no charge is made

Write an algorithm which inputs a request for a sum of money, decides if a withdrawal can be made and calculates any charges. Appropriate output

messages should be included.

[5]

Oct/Nov 2008

19 The manufacturing cost of producing an item depends on its complexity. A company manufactures three different types of item, with costs based on

the following calculations:

Item type 1: item cost = parts cost * 1.5

Item type 2: item cost = parts cost * 2.5

Item type 3: item cost = parts cost * 5.0

The company makes 1000 items per day.

Write an algorithm, using pseudocode, flowchart or otherwise, which

inputs the item type and parts cost of each item

outputs the item cost for each item

calculates and outputs the average (mean) item cost per day (based on 1000 items being made).

[5]

May/June 2009

18 A small airport handles 400 flights per day from three airlines:

FASTAIR (code FA)

SWIFTJET (code SJ)

KNIGHTAIR (code KA)

Each flight is identified by the airline code and 3 digits. For example FA 156.

Write an algorithm, using pseudocode or otherwise, which monitors the 400 flights into and out of the airport each day. The following inputs, processing

and outputs are all part of the monitoring process:

input flight identification

calculate number of flights per day for each of the three airlines

output the percentage of the total flights per day by each airline

any validation checks must be included

[5]

17 (a) A cars speed is measured between points A and B, which are 200 km apart.

[1]

(b) Write an algorithm, using pseudocode or otherwise, which inputs the times for 500 cars, calculates the final speed of each car using the formula in part

(a), and then outputs:

the final speed for ALL 500 cars

the slowest (lowest) final speed

the fastest (highest) final speed

the average final speed for all the cars.

[6]

18 A group of students were monitoring the temperature every day over a one-year period.

Readings were taken ten times every day (you may assume a year contains 365 days).

Write

inputs all the temperatures (ten per day)

outputs the highest temperature taken over the year

outputs the lowest temperature taken over the year

outputs the average temperature per day

outputs the average temperature for the whole year

[7]

16 (a) Write an algorithm, using pseudocode or a flowchart, which:

inputs 50 numbers

outputs how many of the numbers were > 100

[3]

inputs 100 numbers

finds the average of the input numbers

outputs the average

[3]

17 A school is doing a check on the heights and weights of all its students. The school has 1000 students.

Write an algorithm, using pseudocode or a flowchart, which

inputs the height and weight of all 1000 students

outputs the average (mean) height and weight

includes any necessary error traps for the input of height and weight [5]

17 (a) Write an algorithm, using pseudocode or a flowchart, which

inputs a set of positive numbers (which end with -1)

outputs the average (mean) value of the input numbers

outputs the value of the largest (highest) number input

[4]

(b) Write an algorithm, using pseudocode or a flowchart, which

inputs a whole number (which is > 0)

calculates the number of digits in the number

(E.g. 147 would give an output of 3, 147)

[4]

17 Daniel lives in Italy

Country

Mexico

India

New Zealand

and travels

Hours

-7

+4

+11

Minutes

0

+30

0

(a) Write an algorithm, using pseudocode or otherwise, which:

Inputs the name of the country

Inputs the time in Italy in hours (H) and minutes (M)

Calculates the time in the country input using the data from the table

Outputs the country and the time in hours and minutes

[4]

(b) Describe, with examples, two sets of test data you would use to test your algorithm.

[2]

17 A school has 1800 students. The start date and leaving date for each student is stored on file. Dates are in the format YYMMDD (e.g. a student starting

on 10th September 2007 and leaving on 4th August 2012 has the data 070910 and 120804 on file).

(a) Write an algorithm, using pseudocode or otherwise, which

inputs Student ID for all 1800 students

inputs the start date and leaving date for each student

carries out a check to ensure the second date is later

if error, increments error counter

outputs the number of errors

[5]

(b) Describe, with examples, TWO sets of test data you would use to test your algorithm.

17 (a) Write an algorithm, using pseudocode or flowchart only, which:

inputs three numbers

outputs the largest of the three numbers

[2]

inputs 1000 numbers

outputs how many of these numbers were whole numbers (integers)

(You may use INT(X) in your answer e.g. Y = INT(3.8) gives the value Y = 3)

16 The weather conditions in a town are being monitored over a year (365 days). The values recorded per day are weather type and temperature (e.g.

CLOUDY, 25).

Write an algorithm, using pseudocode or flowchart only, which:

inputs the weather type and temperature for each day

outputs the number of days that were CLOUDY, RAINING, SUNNY or FOGGY

outputs the highest recorded temperature for the year

outputs the lowest recorded temperature for the year

17 Write an algorithm, using pseudocode or a program flowchart only, which:

inputs the population and land area for 500 countries,

calculates the population density (i.e. population/land area) for every country,

outputs the largest and smallest population density,

outputs the average population for all 500 countries.

[6]

15 An estate agent advertises houses for sale. The customer enquiries for a 7-day working week are entered weekly into a computer.

Write an algorithm, using pseudocode or a program flowchart only, which:

inputs the number of customer enquiries each day,

inputs the house price each customer enquires about,

outputs how many customers enquired each day about houses costing less than $100 000,

outputs the percentage of all enquiries made during the week about houses costing more than $500 000.

17 (a) Write an algorithm, using pseudocode or a program flowchart only, that:

inputs a series of positive numbers (-1 is used to terminate the input),

outputs how many numbers were less than 1000 and

outputs how many numbers were greater than 1000.

[4]

[6]

inputs fifty numbers each as 4 separate digits, for example: 1 5 4 1

outputs the percentage of numbers that were palindromes.

(note: a palindrome reads the same way backwards or forwards. For example, 1331 is a palindrome but 1541 is not).

Use separate variables to store the separate digits of a number (for example D1, D2,

D3, D4).

[4]

16 A small caf sells five types of item:

bun 0.50 dollars

coffee 1.20 dollars

cake 1.50 dollars

sandwich 2.10 dollars

dessert 4.00 dollars

Write an algorithm, using pseudocode or a program flowchart only, which

inputs every item sold during the day,

uses an item called end to finish the days input,

adds up the daily amount taken for each type of item,

outputs the total takings (for all items added together) at the end of the day,

outputs the type of item that had the highest takings at the end of the day.

[4]

2 Name two different types of loop structure in a typical programming language.

Give an example of how ten numbers could be input using the named loop.

16 A small shop uses barcodes which represent 5 digits. The last digit is used as a check digit.

For example:

abcde

01234

The check digit (e) is found by:

multiplying the first and third digits (i.e. a and c) by 3

multiplying the second and fourth digits (i.e. b and d) by 2

adding these four results together to give a total

dividing this total by 10

remainder is check digit (e)

Write an algorithm, using pseudocode or flowchart only, which

[6]

re-calculates the check digit for each number and checks whether the input check digit (e) is correct

outputs the number of barcodes which were entered correctly

[5]

17 A country has four mobile phone network operators. Each mobile phone number has eight digits. The first three digits identify the network operator:

444 Yodafone

555 N2 network

666 Kofee mobile

777 Satsuma mobile

Write an algorithm, using pseudocode or flowchart only, which reads 50 000 eight-digit mobile phone calls made during the day and outputs the number

of calls made on each of the four networks.

[6]

Oct/Nov 2013. P12

16 (a) A greenhouse is being monitored by a computer using 2 sensors. SENSOR1 measures the temperature and SENSOR2 measures oxygen levels.

If the temperature exceeds 45C or oxygen levels fall below 0.19, then an error message is output by the computer.

Write an algorithm, using pseudocode or flowchart only, which

inputs both sensor readings

checks the sensor input values and outputs a warning message if either are out of

range

continues monitoring until the <ESCAPE> key is pressed

(You may assume that READ SENSORn will take a reading from SENSORn and that

READ KEY inputs a key press from the keyboard).

[5]

15 5000 numbers are being input which should have either 1 digit (e.g. 5), 2 digits (e.g. 36), 3 digits (e.g. 149) or 4 digits (e.g. 8567).

Write an algorithm, using pseudocode or flowchart only, which

inputs 5000 numbers

outputs how many numbers had 1 digit, 2 digits, 3 digits and 4 digits

outputs the % of numbers input which were outside the range

[6]

15 A survey is being carried out which involves reading and recording sound levels near a busy road junction. Once all the data are collected, they are

input manually into a computer. A sound level of 0 decibels (0 dB) is input to indicate the end of the data.

Write an algorithm, using pseudocode or a flowchart, which:

inputs all the sound levels

after a sound level of 0 is input, outputs the following:

o average sound level

o highest recorded sound level.

18 A school has 1500 students. It is conducting a survey on their music preferences. Each student uses a computer and inputs their name and then

chooses one of 5 options:

rock (input value 1)

soul (input value 2)

pop (input value 3)

jazz (input value 4)

classical (input value 5)

Write an algorithm, using pseudocode or a flowchart, which:

inputs the choice of all 1500 students (values 1 to 5)

outputs all the names of the students who chose classical music

outputs the percentage who chose each option.

- Olevel Computer Science Notes (2210)Diunggah olehKhawaja Shoaib
- A Levels Computing 9691 Revision NotesDiunggah olehMuhammad Ahmad Faraz
- Pre-released Material for June 2015 FinalDiunggah olehDB
- Notes Logic GateDiunggah olehVishal Paupiah
- Robotics & AutomationDiunggah olehLungmuaNa Rante
- PA8-Solution_29428 (1)Diunggah olehNatalie Vatavalis
- 9691-01 Revision Notes (Modified F451)Diunggah olehChew Shu Ren
- A2 computer Science - Computer Networking ProblemsDiunggah olehEdgardo Leysa
- GenFam Algo and Meeting NotesDiunggah olehUmme Rabab Syed
- Wireless, Distributed Modalities.pdfDiunggah olehajitkk79
- 2.Direct_Digital_Control.pptxDiunggah olehPrasanth Chitturi
- ObesityDiunggah olehAnalisa Podgorski
- Boys ChartDiunggah olehRosi Ahava
- ksde standard 9 artifactDiunggah olehapi-242139036
- ctrendsunit6elderlyDiunggah olehapi-250256758
- DevelopmentDiunggah olehTusharBhattacharya
- BMI and DiabetesDiunggah olehLucyellowOttemoesoe
- Chap8Diunggah olehtejashraj93
- Maquinas de EstadosDiunggah olehLeonardo Merchan
- o Level Computer ScienceDiunggah olehTrynos
- Part 1 of 1.docxDiunggah olehAyatokun
- Technical Material ReferenceDiunggah olehaiindustriyahoocoid
- Lecture_01-Introduction to ProgrammingDiunggah olehraja haris
- Markov ModelsDiunggah olehJohn
- Smokers Hair Indian Dermatology Online Journal 2013Diunggah olehyaya1yaya1
- 1-s2.0-S2405844018303001-main.pdfDiunggah olehAnca Bianca
- No ContentDiunggah olehgabriel
- HjDiunggah olehyunda
- PRACTICAL BOILER OPERATION ENGINEERING AND POWER PLANT.pdfDiunggah olehRahul Singh
- 5 Ideas for Teaching ComputingDiunggah olehDon Mark

- 9608_s15_ms_11Diunggah olehTrynos
- CompDiunggah olehTrynos
- f453 revision guideDiunggah olehYasinAttia
- CPU ArchitectureDiunggah olehTrynos
- 9691 May June 2011 All Question PapersDiunggah olehTrynos
- 9691_s08_qp_3Diunggah olehTrynos
- 9608 June 2015 Question Paper 13Diunggah olehaniket6969
- 9691_May-June-2011-All-Question-Papers.pdfDiunggah olehTrynos
- 9691 Oct Nov 2011 All Question PapersDiunggah olehTrynos
- 9608_s15_qp_11Diunggah olehTrynos
- 9691_s15_qp_32Diunggah olehTrynos
- 9691_w11_qp_33Diunggah olehTrynos
- 0478_y17-19_sy.pdfDiunggah olehTrynos
- 9691_s12_qp_13Diunggah olehTrynos
- 9706_s11_ms_41Diunggah olehHAHA_123
- 9691_s12_ms_13Diunggah olehTrynos
- 285020 Topic 4.2.3 State Transition Diagrams 9608 (1)Diunggah olehTrynos
- 4.2.1 Decision TablesDiunggah olehTrynos
- 1.3.3 Logic Gates and Logic CircuitsDiunggah olehTrynos
- Computer Science Teacher Guide 2014Diunggah olehmtaruna
- 1.1.3 Data storageDiunggah olehTrynos
- 1.3.4 Output Devices (1)Diunggah olehTrynos
- First TermDiunggah olehTrynos
- 9231_w14_ms_21Diunggah olehTrynos
- Aqa Comp2 Qp Jan13Diunggah olehTrynos
- Aqa Comp2 w Ms Jun13Diunggah olehTrynos
- Aqa Comp3 Qp Jun14Diunggah olehTrynos
- o Level Computer ScienceDiunggah olehTrynos
- Pre Release MaterialDiunggah olehTrynos
- Practical Paper Review NotesDiunggah olehTrynos

- DMXR100_QuickRefDiunggah olehKonstantinos Lianos
- manual-samsungM2022W.pdfDiunggah olehChirita Alexandra
- Shirikiana Shared Services Master Plan 2011Diunggah olehICT AUTHORITY
- ReadMeDiunggah olehNick Timman
- B082Diunggah olehSaileshResume
- pplsoftDiunggah olehsmarrahman
- Intel Family ProcessorDiunggah olehWinterLopezII
- 2-1_FJGP4D_BrochureDiunggah olehRohant Goyal
- Soumik_Roy_J2EE_7.5yrsDiunggah olehHillol Pal
- WEB_2.0Diunggah olehJitendra Singh
- Azure Virtual NetworkDiunggah olehCristiano Petry
- 0 - What’s New in Python 3.7.2Diunggah olehAaa Mmm
- Corporate Banking Relationship Management SolutionsDiunggah olehInfosys
- Atoll 3.3.0 LTE TechnologiesDiunggah olehBinh Nguyen Thai
- CORE ROUTERDiunggah olehRichard Pascual
- Consult as Adventure WorksDiunggah olehaldemar
- UML and WirelessDiunggah olehMiljan Jeremic
- afdaDiunggah olehGoran Petkovic
- Fanuc Automation ProgramingDiunggah olehJasonMcBride
- What is P-Delta EffectDiunggah olehJoshua Lara
- Detailed Lesson Plan in CSSDiunggah olehIan Bagunas
- CEPSI 2014 - Triangular Coordination Between Utility Supplier and Contractors - Ignatius RendroyokoDiunggah olehrendroyoko
- bdl_2.10Diunggah olehMiguel Jiménez
- Pbpro_244Diunggah olehCamilo Blanquiv
- BACnet and Modbus RTUDiunggah olehalejandro
- eplan manualDiunggah olehAyman Qunaibi
- Scrip Clase 06.OctubreDiunggah olehMaribel Condori Suca
- Tech Info - RS232 Cables and WiringDiunggah olehAntonio
- Unlock-downloadDiunggah olehMahendra V Patel
- RADDiunggah olehGiovanbattista Celato