Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

PWD – MODEL QUESTIONS & ANSWERS

FND08PWD - Programming & Web Development

Question 01 - DONE
Write a program that counts the even and odd numbers from 1 to a given positive integer.
The program should use iteration to perform the calculation.
Requirement
• Prompt a user to input the positive number
• Validate that the entered value is a positive number.
• Display the total count of even and odd numbers separately.

Coding – Scratch Programming Algorithm – Pseudocode

START
SET EVEN = 0, ODD = 0, N = 1
READ “Enter a positive number?”
STORE in variable VALUE
IF (VALUE > 10) THEN
REPEAT (N < VALUE)
IF (N mod 2 = 0) THEN
EVENT = EVENT + 1
ELSE
ODD = ODD + 1
END IF
N=N+1
END REPEAT
PRINT “Total Even Nos: + EVEN
PRINT “Total Odd Nos:”+ ODD
ELSE
PRINT “Invalid number!”
END IF
END
Question 02 - DONE
Write a program for a shop to calculate the total for three items and the balance to be given
for the customer.
Requirement
• Prompt the user to enter the quantity & price of the item purchased.
• Repeat the above step for the next two items using a loop.
• Prompt the user to enter the cash in.
• Display the total of the three items purchased, along with the balance.

Coding – Scratch Programming Algorithm – Pseudocode

START
SET TOTAL = 0, COUNTER = 1
REPEAT (COUNTER < 3)
READ “Enter the price?”
STORE in variable PRICE
READ “Enter the quantity?”
STORE in variable QTY
TOTAL = TOTAL + (PRICE * QTY)
COUNTER = COUNTER + 1
END REPEAT
READ “Enter the cash in value?”
STORE in variable CASHIN
BALANCE = CASHIN – TOTAL
PRINT “Total:” + TOTAL
PRINT “Balance:” + BALANCE
END
Question 03
Write a program that accepts three positive number inputs, and find the biggest and smallest
number from the series. (Maximum number value is 100)
Requirement
• Prompt the user to input three numbers
• Validate that all the user input as if it is a positive number.
• Display the biggest and smallest numbers separately.

Coding – Scratch Programming Algorithm – Pseudocode


START
SET BIG = 0, SMALL = 100, COUNTER
=1
REPEAT (COUNTER < 3)
READ “Enter the number?”
STORE in variable N
IF (N > 0 AND N < 100) THEN
IF (N > BIG) THEN
BIG = N
END IF
IF (N < SMALL) THEN
SMALL = N
END IF
COUNTER = COUNTER
+1
ELSE
PRINT “Invalid No,
Please try
again!”
END IF
END REPEAT
PRINT “Biggest No:” + BIG
PRINT “Smallest No:” + SMALL
END
Question 04
Write a program that changes meters (m) to centimeters (cm) and millimeter (mm). The
program should allow the user to enter in the number of meters and then print out the
number of centimeters and millimeters. (1 M = 100 CM & 1 CM = 10 MM)
Requirement
• Prompt the user to enter meter as a number.
• Display the numbers in Centimeters and Millimeters separately.
• Repeat the unit conversion until the user decides to exit.

Coding – Scratch Programming Algorithm – Pseudocode


START
SET REPLY = “yes”
REPEAT (REPLY = “yes”)
READ “Enter the number
(in Meters)?”
STORE in variable M
CM = M * 100
MM = CM * 10
PRINT “Centimeter: ” + CM + “cm”
PRINT “Millimeter:” + MM + “mm”

READ “Do you wish to


continue (yes / no)?”
STORE in variable REPLY
END REPEAT
END
Question 05
Write a program that will allow a user to enter a number of scores until -9 is entered. When -
9 is entered, print the average of the scores entered. Use a loop and ensure scores entered
before calculating the average.
Requirement
• Prompt the user to enter the score until -9 is entered.
• Display the average from the total scores entered.

Coding – Scratch Programming Algorithm – Pseudocode


START
SET COUNTER = 0, TOTAL = 0
REPEAT (TRUE)
READ “Enter the score?”
STORE in variable SCORE
IF NOT (SCORE = -9) THEN
TOTAL = TOTAL + SCORE
COUNTER = COUNTER + 1
ELSE
AVERAGE = TOTAL / COUNTER
PRINT “Average Score:”
+ AVERAGE
EXIT REPEAT
ENDIF
END REPEAT
END
Question 06
Write a program that calculates the total and average of a student’s marks for three subjects,
and grade the students based on their average using the below table. Use a loop to question
the marks for each subject.

A – 70 & Above
B – 50 & Above
C – 30 & Above
FAIL – Below 30

Requirement

• Prompt the user to enter the mark (input) for each subject individually.
• Display the calculated total, average and the grade.

Coding – Scratch Programming Algorithm – Pseudocode


START
SET COUNTER = 1, TOTAL = 0, GRADE = NULL
REPEAT (COUNTER < 3)
READ “Enter the marks?”
STORE in variable MARKS
TOTAL = TOTAL + MARKS
COUNTER = COUNTER + 1
END REPEAT
AVERAGE = TOTAL / 3
IF (AVERAGE > 69 AND AVERAGE < 101) THEN
GRADE = A
END IF
IF (AVERAGE > 49 AND AVERAGE < 70) THEN
GRADE = B
END IF
IF (AVERAGE > 29 AND AVERAGE < 50)) THEN
GRADE = C
END IF
IF (AVERAGE < 30) THEN
GRADE = FAIL
END IF
PRINT “Total:” + TOTAL
PRINT “Average:” + AVERAGE
PRINT “Grade:” + GRADE
END

You might also like