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

Pseudo Code Examples

The document contains 7 code snippets that calculate various metrics based on input values. The first calculates excess luggage fees for an airline based on weight. The second determines the price of potato bags based on quantity bought. The third calculates electricity bills based on consumption tiers. The fourth computes delivery costs for packages based on weight. The fifth finds bank cheque processing fees based on number of cheques. The sixth calculates subject marks totals and averages for a student. The seventh finds the average of a set of numbers entered and terminated by zero. All use conditionals like if/else statements to categorize inputs and determine outputs.

Uploaded by

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

Pseudo Code Examples

The document contains 7 code snippets that calculate various metrics based on input values. The first calculates excess luggage fees for an airline based on weight. The second determines the price of potato bags based on quantity bought. The third calculates electricity bills based on consumption tiers. The fourth computes delivery costs for packages based on weight. The fifth finds bank cheque processing fees based on number of cheques. The sixth calculates subject marks totals and averages for a student. The seventh finds the average of a set of numbers entered and terminated by zero. All use conditionals like if/else statements to categorize inputs and determine outputs.

Uploaded by

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

1. ProNet Airline services provides a luggage allowance of 35Kg.

For each exceeding Kilograms, ProNet airline


charges a flat rate of Rs.1500 per Kg. Obtain the weight of the luggage and display if it is within allowed limit
or fee for excess luggage.
Main
prompt for weight
get weight
if (weight <= 35) then
print " The Laggage within allowed limit"
else
excess_charge = (weight - 35) * 1500.00
print "Laggage with excess weight"
print "The Additional Chrage: " ,excess_charge," Rs."
endif
End

2. ProNet wholesalers sells 50 KG bags of potatoes. The price per bag is dependent on the number of are sold.
Determine the total price depending on the number of bags sold.
Amount of bags
Price per bag
15
Rs.1250
6 25
Rs.1000
More than 26
Rs. 800
Main
prompt for no_of_bags
get no_of_bags
if (no_of_bags >50)then
print "Sorry we are out of stock"
price_per_bag = 000
else
if ( no_of_bags > 26) then
price_per_bag = 800
elseif(no_of_bags > 6) then
price_per_bag =1000
elseif(no_of_bags <= 5 )then
price_per_bag =1250
else
print "Invalid number"
endif
endif
total_price = no_of_bags * price_per_bag
print "No Of Bags ",no_of_bags,"Price Per Bag",price_per_bag,"Total: "
,total_price
End

3. The charge for domestic energy (electricity) consumption is calculated as on the following table. An
application has to be created to calculate the total charge based on the electricity consumption.
Units

Energy charge (per unit in Rs.)

The Charge For First 62 Units (Up To 62 Units)

7.85

The Charge For Next 31 Units (Up To 93 Units)

10.00

The Charge For Next 31 Units (Up To 124 Units)

27.75

Fixed Charge (Above 124 Units)

54.00

Main
prompt for units
get units
if (units >124)then
total_charge = units * 54
elseif (units > 93 ) then
total_charge = 62 * 7.85 + 31* 10 +(units-93)* 27.75
elseif (units > 62 ) then
total_charge = 62 * 7.85 +(units-62)* 10
elseif(units <= 62) then
total_charge = units * 7.85
else
print "invalid units"
endif
print "Bill Amount Is :", total_charge
End

4. ProNet postal delivery services needs to calculate the total cost of delivering a parcel. ProNet delivery
charges are based on the weight of the package is on following table
Weight of the package

Charge per Kg

Less than 2Kg

Rs. 1,000

2Kg 6 Kg

Rs. 2,000

6Kg 10Kg

Rs. 3,000

More than 10Kg

Rs. 3,500

Main
prompt for weight
get weight
if (weight > 10)then
total_cost = weight * 3500
elseif (weight > 6 ) then
total_cost = weight * 3000
elseif (weight >= 2 ) then
total_cost = weight * 2000
elseif(weight < 2) then
total_cost = weight * 1000
else
print "invalid units"
endif
print "Total chrage Is :", total_cost
End

5. Application has to be created to calculate the total cheque processing fee for a fictitious bank. Bank charges
a base fee of Rs. 1000 per month, plus the following cheque fees based on the number of cheques
Number of cheques

Charge

Less than 20 cheques

Rs. 100 (per cheque)

21 39 cheques

Rs. 80 (per cheque)

40 59 cheques

Rs. 60 (per cheque)

60 or more

Rs. 40 (per cheque)

Main
prompt for noOfCheque
get noOfCheque
if (noOfCheque >= 60)then
total_cost = (noOfCheque * 40)+ 1000
elseif (noOfCheque >=40 ) then
total_cost = (noOfCheque * 60)+ 1000
elseif (noOfCheque >= 20 ) then
total_cost = (noOfCheque * 40)+ 1000
elseif(noOfCheque < 20) then
total_cost = (noOfCheque * 100)+ 1000
else
print "invalid units"
endif
print "Total chrage Is :", total_cost
End

6. A student enrolled for an undergraduate course can take one to four subjects per semester. Obtain the
number of subjects and mark for each subject, calculate and display the total and the average of the subjects
attempted that semester.
Main
prompt for noOfSubjects
get noOfSubjects
if (noOfSubjects < 1 or noOfSubjects > 4) then
print " No of Subjects can be 1- 4"
else
counter = 1
total = 0
average = 0
while ( counter <= noOfSubjects)
prompt for marks
get marks
total = total + marks
average = total / counter
counter = counter + 1
endwhile
Print " Total",total,"Average",average
endif
End

7. An average calculator should be created to accept a set of numbers terminated by zero, calculate the
average of the given set of numbers
Main
prompt for how_many_numbers_in_the_set
get how_many_numbers_in_the_set
count = 1
total=0
while(count<= how_many_numbers_in_the_set )
prompt for number
get number
check = number % 10
if((check==0)) then
total = total + number
count = count + 1
else
print "number not terminated by Zero"
count =count-1
endif
endwhile
average = total/count
print "Total: " ,total
print "Average: " ,average
End

You might also like