hi welcome to quixotic academy in
this video we will discuss
pre-release material for O-level
computer science paper 2
october november let's have a look at
the pre release material
there is an online computer shop that
sells customized personal computers every
computer sold
includes a basic set of components
costing 200
it means that every basic computer a
customer buys
is of 200 that is the minimum price
at the shop next additional items can be
added from the table
so this table contains all the
additional items that a customer can buy
with
his customized computer these items
include case ram
hard disk drive solid state drive second
hardest drive optical drive and
operating system we will look at it
again
later. As well as the basic set of
components every computer must include
one case
one ram and one main harness drive from
the table
it means this is the starting price 200
then one from the case
and one item from the ram and one item
from the main hard disk drive has to be
selected to buy a computer
so these three things are required
Then a computer is supplied with or
without an operating system
so the operating system is not required
but
each one of these is important
it is require. What we have to do is
write and test a program
or programs for the online computer shop
your program or  programs
must include appropriate prompts for the
entry of data
data must be validated on entry this
is very important point do not skip it
in
any case error messages and other output
need to be set up clearly and
understandably which means all the
categories codes description and prices
need to be displayed properly
in a proper readable manner
next is all areas variables constants
and other identifiers must have
meaningful names this
is also a required step in every program
you do
okay moving on to task one uh before
moving on to
task one let's see how many variables
we can identify from here one is the
basic set of cost which is 200
and we have to use some variable which
will
display the category we have to use some
variable which will display the item
code the description
and the price
this is something we can tell at one
look that we need these variables
next they said that every computer must
include one case one ram and one main
hard drive it means we have to
use some variable to select these okay
so moving on to task one setting up the
system
and ordering the main items write a
program to use arrays
to store the item code description and
price
allow a customer to choose one case one
ram and one main hard drive
so first of all we will use arrays they
have told us to use
arrays so we have to use the arrays here
we will uh keep an array for all the
categories we will keep
one array for all the codes we will keep
one array for all the descriptions
and one for the price also the data type
has to be mentioned
so it is obvious that these three are of
string data type because
this contains some text some some
alphabet some numeric values since
prices
are folding point numbers so this array
will be of type
float let's start writing the pseudocode
we have already assessed these variables
from the
text written in the task so we have
basic price containing 200
in start we have item category and
array that contains
all the categories provided in the table
and the same sequence here
then we have item codes and we have item
descriptions
same sequence then we have item prices
prices are
with decimal points so this is a float
array we have already talked about it
next task is to allow a customer to
choose
one case one ram and one main hard
drive it means we have to display
uh the cases first the customer will see
there are two cases available a1 and a2
he'll see the description the prices
then choose any one from them
and we will add the chosen item in a
list
because we have to calculate the price
in the end next the customer
will see all the rams available and
choose one
next the customer will see main hard
drives available and then choose one
so here we have to display these prices
descriptions properly
in an understandable manner first a customer
will choose
a case so we are using a loop here
because we know that there are only two
cases
and we use for loop when we want to iterate for
a predefined range so our range is from
zero to one
since you are already programming in
high level languages you know that
arrays index start from zero so there is
no problem using the zero in pseudocode
as well
so what we are saying is from zero to
one
from this index to this index print the
following
so we are saying press one
.first time we are saying press zero
for item category is case because
at the zeroth index there is case we are
using this
case value as an index to all of these
arrays
so the item category is case
the item code is a1 the item description
is compact the item price is 75
in the next iteration we are saying
press
1 for case a2
tower 150 this way
we are displaying all the items to the
customer in
an understandable readable and friendly
manner
so you can choose properly next there is
a variable called item category location
so i have used this variable to locate
the
specific items from this list okay
so item category location is zero for
the cases
because first case arrives at the zeroth
index
if i want to use the ram values
i will say item category location is 0
1 2 because rams are starting from the
second index then if i want to use
main hard drives i will say item
category location
is 0 1 2 3 4
5 you will see the
impact of this variable later is very
useful
after seeing all the description and
prices the customer will choose one item
from this list
so we have already said that
press 0 for first and we have already
set that press 1 for this
so after taking the input we will verify
that the user has to press
0 or 1 so here we are performing the
validation
if a while choose an item is not zero or
choose an item is not
one two uh we will print again
press zero or one and again take the
input again validate the input and this
will go on
until the correct input has been passed
the task one also require
us to store the and output the chosen
items
and the price of computer so it means
whichever case has been selected
has to be displayed in the end
we have declared a new array choose an
item list in this array we will keep all
the chosen
selected items to display in the end
we will append the append means we are
adding
a new item in the array previously there
it was empty
we have chosen one item so we are going
to add that in the
list in the array so we are going to
append the item category location plus
choose an item
i have already told you we are going to
use item category location to locate
the position of the item in these areas
since cases are at the index 0 so we are
going to say that for example the user
has
entered zero here he want to buy the
first case
so at that time the choose an item list
will have
zero because item category location is
zero
and the input is also zero zero plus
zero is zero it means that
the case a one
which whose description is compact whose
price is 75
has been chosen by the customer
similarly if the two if the user selects
second case
if the user enters two sorry second case
means the user has to press
one if the user presses 1
we will say that store 0 plus 1 in this
list it means store case
a2 tower and 150 price as a choose an
item
next we will display all the rams
available
before that we have to change the value
in the variable
item category location because now we
want to display the rams here
so we will say the uh we will set the
item category location
uh two zero one two so
the index of ram is two
so here we have set it two then we will
print
a proper statement saying please select
one ram from the following
now we have also increased the
iterations here
we want to iterate from zero to two
because there are
three rams available while we were
selecting the case
only two cases were available so we used
zero to one
now there are three rams so all four
loop will i trade three times so we are
saying from zero to two it means zero
one
and two so we will again print the
we will say press 0 for
ram b1 8gb for the price of 79
press 1 for the ram b2 uh
with 16 gb and the price of 149
and press 2 for the ram b3
32gb and the price of
299. after we have displayed everything
we will again take the input and the
variable choose an item
we don't have to uh keep separate
variables for all the chosen items
because we are already keeping a list
we are already keeping this list so we
will again use the variable choose an
item
the customer will enter zero one or two
we will verify and validate
if zero one or two is not pressed we
will ask for input again
and we will add the choose an item in
the chosen item list again
you see now item category location is 2
if the user presses 0 he wants to
buy ram number 1 so he will press 0
we will add in the list 0 plus
2 as you can see 0 plus 2 leads us
here that's why we have used an
item category location variable the name
is
meaningful we want to locate it in the
list and this will help us
keep the choose an item list tidy and
organized
we will write the same pseudo code to
take input of
main hard drive there are three hardest
drives are available
so again we have
displayed a loop from zero to two
or we have changed the item category
location to five now because a series
are placed
uh starts from the next five we are
again
taking the input validating the input
and storing in the chosen item list
next task is to calculate the price of
computer using the cost of choosing
items
and the basics out of component store
and
output the chosen items and the price of
the computer so now
we have we know that uh the customer has
chosen one case one ram
and one agv we have to calculate the
price and displays the
chosen i we have final price equal to
basic price at the beginning
because uh basic price of 200 is preset
predefined
next we will display all the chosen
items
and calculate their prices as well we
have initialized a loop
a counter variable is used in the loop
this
will run from 0 to the length of choose
an item list
so length is a keyword to calculate the
length of something
and it is available in almost all high
level languages
so we will locate the item
using the value in choose an item list
so for example if the case 0 was
selected choose an item list will have
0 here if the case 0 was selected choose
an item list will have 0
and the item category 0
the item codes 0 is index the item
description 0 index and the item prices
zero the index has been
accessed to display the uh related
values then we will add the
price in the final price thank you for
watching we will continue the discussion
in next couple of videos
if you have any questions please do
comment i will try to answer
all of them
