0% found this document useful (0 votes)
79 views

Computer Science Questions From Chapter 10 For Class 10 11

This document contains the answers to 8 questions about computer science asked by a teacher. For question 1, the student shows two ways to use pseudocode for conditional statements - an if/else statement and a case statement. For question 2, the student chooses to use a case statement for a menu and provides the pseudocode. For question 3, the student explains three ways to use loops to add 5 numbers - a for loop, repeat until loop, and while loop.

Uploaded by

김민재
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Computer Science Questions From Chapter 10 For Class 10 11

This document contains the answers to 8 questions about computer science asked by a teacher. For question 1, the student shows two ways to use pseudocode for conditional statements - an if/else statement and a case statement. For question 2, the student chooses to use a case statement for a menu and provides the pseudocode. For question 3, the student explains three ways to use loops to add 5 numbers - a for loop, repeat until loop, and while loop.

Uploaded by

김민재
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

The City School

North Nazimabad Boys Branch

Date: 12-Nov-2016
Class: 10 & 11
Subject: Computer Science
Teacher: Lubna Tanweer
Q1: Show two ways of selecting different actions using Pseudocode.

Ans:

If Condition

Begin

Input grade

If grade >= 60

Then Print "passed"


Else Print "failed"
End If

End

Case Statement

Begin
Input grade
CASE grade OF
‘A’ : points = 4
‘B’ : points = 3
‘C’ : points = 2
‘D’ : points = 1
‘F’ : points = 0
ENDCASE
Output points
End

Q2: You have been asked to choose the correct routine from the menu shown below.

a) Decide which type of conditional statement are you going to you use.
b) Explain your choice.
c) Write the Pseudocode
d) Select your test data and explain why you choose each value.

Answer:

a) I am using Case Statement


b) because it is very simple and relevant to use in the given scenario.
c) Pseudocode:

Begin

Input Choice

Case Choice of

1 : SetUpNewAccount;

2 : MakeChangesToAnExistingAccount;

3: CloseAnAccount;

4 : ViewMyOrders;

5 : PlaceANewOrder;

6 : AlterAnExistingOrder;

0 : Exit;

H : Help;

End Case

End

Q3: Show three ways to use a loop to add up five numbers and print out the total can be set up using
Pseudocode. Explain which loop is the most efficient to use.

Answer:

There are three different loop structures that we can use to add five numbers.

1) By Using For Loop

Begin

Sum=0

For Count = 1 to 5
Input Num

Sum = Sum + Num

Next Count

Output “Total = ”, Sum

End

2) By Using Repeat Until Loop

Begin

Sum=0

Count = 0

Repeat

Input Num

Sum = Sum + Num

Count = Count + 1

Until Count = 5

Output “Total = ”, Sum

End

3) By Using While Do EndWhile Loop

Begin

Sum=0

Count = 0

While Count<5 Do

Input Num

Sum = Sum + Num

Count = Count + 1

EndWhile
Output “Total = ”, Sum

End

Q4: A sweets shop sells five hundred different types of sweets. Each sort of sweet is identified by a
different four digit code. All sweets that start with 1 are Chocolates, All sweets that start with 2 are
toffees, All sweets that start with 3 are jellies and all other sweets are miscellaneous and can start with
any other digit except zero.

a) Write an algorithm, using a flowchart or Pseudocode which input the four digit code for all 500
items and output the number of chocolates, toffees and jellies.
b) Explain how you would test your flow chart.
c) Decide the test data to use and complete a trace table showing a dry run of your flow chart.

Answer:

Begin
TotalChocolate = 0
TotalToffees = 0
TotalJellies = 0
For Count = 1 to 500
Input Code
If Code >= 1000 And Code <=1999
Then TotalChocolate = TotalChocolate + 1
Else
If Code >= 2000 And Code <=2999
Then TotalToffees = TotalToffees + 1
Else
If Code >= 3000 And Code <=3999
Then TotalJellies = TotalJellies + 1
End If
End If
End If
Next Count
Output “Total Number Of Chocolates :” , TotalChocolate
Output “Total Number Of Chocolates :” , TotalToffees
Output “Total Number Of Jellies :” , TotalJellies
End

Q5: The temperature in an apartment must be kept between 18⁰C and 20⁰C. If the temperature
reaches 22⁰C then the fan is switched On; If the temperature reaches 16⁰C then the heater is
switched On; otherwise the fan and the heater are switched Off. The following library routines
are available:
 GetTemperature
 FanOn
 FanOff
 HeaterOn
 HeaterOff
Write an algorithm using Pseudocode or flow chart, to keep the temperature at the right level.
Begin
Input Temperature
If Temperature >= 22
Then FanOn;
Else
If Temperature <= 16
Then HeaterOn;
Else
FanOff;
HeaterOff;
End If
End If
End
Q6: Daniel lives in Italy and travels to Mexico, India and New Zealand. The time difference 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 which:
 Inputs the name of the country
 Inputs the time in Italy in hours and in minutes
 Calculate the time in the country input using the data from the table
 Output the country and the time in hours and in minutes.
b) Describe with examples two sets of test data you would use to test your algorithm.
a)
Begin
Input Country, Hours, Minutes
If Country = “Mexico”
Then Hours = Hours - 7
Else
If Country = “India”
Then Hours = Hours + 4
Minutes = Minutes + 30
If Minutes > = 60
Minutes = Minutes – 60
Hours = Hours + 1
End If
Else
If Country = “New Zealand”
Then Hours = Hours + 11
End If
End If
End If
End
Q7: A school is doing a check on the heights and weights of the students. The school has 1000
students. Write a Pseudocode and program in VB, which:
 Input height and weight of all 1000 students
 Output the average height and weight
 Include any necessary error traps for the input
Begin
TotalWeight =0
TotalHeight =0
For x= 1 to 1000
Repeat
Input height, weight
Until (height > 30) and (height < 80) and (weight > 30 ) and ( weight < 100)
TotalWeight = TotalWeight + weight
TotalHeight = TotalHeight + height
Next
AverageHeight = TotalHeight / 1000
AverageWeight = TotalWeight / 1000
Output “ Average height of the students is : ”, AverageHeight
Output “ Average weight of the students is : ”, AverageWeight
End

Q8: A small café sells five types of items:


Bun $0.50
Coffee $1.20
Cake $1.50
Sandwich $2.10
Dessert $4.00
Write a program, which
 Input every item sold during the day
 Uses an item called “end” to finish the day’s 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
 Output the item that had the highest takings at the end of the day
Pseudocode
Begin
Tbun =0
Tcoffee =0
Tcake =0
Tsandwich = 0
Tdessert =0
HighestTaking = 0
Repeat
Input Item, quantity
Case Item of
“bun” : Tbun = Tbun + quantity
“coffee” : Tcoffee = Tcoffee + quantity
“cake” : Tcake = Tcake + quantity
“sandwich” : Tsandwich = Tsandwich + quantity
“dessert” : Tdessert = Tdessert + quantity
Otherwise Output “ Enter relevant product ”
End Case
Until Item = “End”
TotalTakings = Tbun + Tcoffee + Tcake + Tsandwich + Tdessert
Output “The total takings of the whole day” , TotalTakings

If (Tbun > HighestTaking) Then


HighestTaking = Tbun
Item = “Bun”
End If
If (Tcoffee > HighestTaking) Then
HighestTaking = Tcoffee
Item = “Coffee”
End If
If ( Tcake > HighestTaking) Then
HighestTaking = Tcake
Item = “Cake”
End If
If ( Tsandwich > HighestTaking) Then
HighestTaking = Tsandwich
Item = “Sandwich”
End If
If (Tdessert > HighestTaking) Then
HighestTaking = Tdessert
Item = “Dessert”
End If
Output “The item which has the highest sales today is : ” , Item
End
VB program
Module Module1
Sub Main( )
Dim Tbun, Tcoffee, Tcake, Tsandwich, Tdessert, quantity, TotalTakings, HighestTaking As Integer
Tbun =0
Tcoffee =0
Tcake =0
Tsandwich = 0
Tdessert =0
Dim Item As String
Do
Console.writeline ( “Enter the item in lower case only”)
Item = console.readline( )
Console.writeline ( “Enter its quantity”)
quantity = Int(console.readline( ))
Select Item
Case “bun”
Tbun = Tbun + quantity
Case “coffee”
Tcoffee = Tcoffee + quantity
Case “cake”
Tcake = Tcake + quantity
Case “sandwich”
Tsandwich = Tsandwich + quantity
Case “dessert”
Tdessert = Tdessert + quantity
Case Else
Console.writeline(“ Enter relevant product ”)
End Select
Loop Until ( Item = “End” )
TotalTakings = Tbun + Tcoffee + Tcake + Tsandwich + Tdessert
Console.writeline(“The total takings of the whole day” & TotalTakings)
If (Tbun > HighestTaking) Then
HighestTaking = Tbun
Item = “Bun”
End If
If (Tcoffee > HighestTaking) Then
HighestTaking = Tcoffee
Item = “Coffee”
End If
If ( Tcake > HighestTaking) Then
HighestTaking = Tcake
Item = “Cake”
End If
If ( Tsandwich > HighestTaking) Then
HighestTaking = Tsandwich
Item = “Sandwich”
End If
If (Tdessert > HighestTaking) Then
HighestTaking = Tdessert
Item = “Dessert”
End If
Console.writeline(“The item which has the highest sales today is : ” & Item)
Console.readkey( )
End Sub
End Module
Q9: 5000 numbers are being input which should have either one digit, two digits, three digits or four digits. Write an
algorithm which:
 Input 5000 numbers
 Output how many numbers have one digit, two digits, three digits and four digits.
 Output the percentage of numbers which were outside the range.

Begin
OneDigit = 0
TwoDigit = 0
ThreeDigit = 0
FourDigit = 0
OutSide = 0
For Count = 1 to 500
Input Number
If Number >= 0 And Number <=9
Then OneDigit = OneDigit + 1
Else
If Number >= 10 And Number <=99
Then TwoDigit = TwoDigit + 1
Else
If Number >= 100 And Number <=999
Then ThreeDigit = ThreeDigit + 1
Else
If Number >= 1000 And Number <=9999
Then FourDigit = FourDigit + 1
Else
OutSide = OutSide + 1
End If
End If
End If
End If
Next Count
Percentage = OutSide / 5000 * 100
Output “Total Number Of One Digit Numbers :” , OneDigit
Output “Total Number Of Two Digit Numbers :” , TwoDigit
Output “Total Number Of Three Digit Numbers :” , ThreeDigit
Output “Total Number Of Four Digit Numbers :” , FourDigit
Output “Percentage of numbers outside the range” , Percentage
End

You might also like