logo

Pseudo Code Solutions

This assignment requires students to demonstrate their understanding of programming concepts, problem-solving skills, and algorithm design and development using sequence, selection, and iterative constructs and modularisation.

5 Pages1038 Words420 Views
   

Added on  2023-04-21

About This Document

This document provides pseudo code solutions for various problems. It includes solutions for checking phone number country code, determining mobile phone usage, writing family names and ticket prices, and determining chance of rain based on temperature and humidity.

Pseudo Code Solutions

This assignment requires students to demonstrate their understanding of programming concepts, problem-solving skills, and algorithm design and development using sequence, selection, and iterative constructs and modularisation.

   Added on 2023-04-21

ShareRelated Documents
DOCUMENTATION
1. Solution:
IPO Chart
Input Processing Output
Phone Number
including Country
Code
Processing Item:
Array of Country Code
Array of Corresponding Country Name
Country Name
2. Solution:
Pseudo Code:
// Get the usage of mobile phones per day in minutes
Read mobile_usage_in_minutes
// Convert the mobile phones usage from minutes to hours
Set mobile_usage_in_hours to mobile_usage_in_minutes/60
// Check if the mobile usage is less than 1 hour
If (mobile_usage_in_hours < 1)
// Display the Message - “Usage is acceptable”
Write “Usage is acceptable”
// Check if the mobile usage is between 1 hour and 2 hours
Else if(mobile_usage_in_hours <= 2)
// Display the Message - “Mediocre Usage”
Write “Mediocre Usage”
// if the mobile usage is more than 2 hours
Else
// Display the Warning Message
Write “Warning, using your phone more than 2 hours per day can affect your
health”
3. Solution:
Pseudo Code:
// This module helps to write the family name and its corresponding ticket price
Module WriteToFile (familyNameArray, totalTicketPriceArray)
// open the file “Ticket_Prtice.xlsx” to write the contents
file = Open File named “Ticket_Prtice.xlsx” in Write Mode
//Write the header to the file
WriteLine (file, “Family Name”, “Total Ticket Price”)
// loop for each family in familyNameArray
For index = 0 to len(familyNameArray)
// Write the family name and its corresponding ticket price
WriteLine (file, familyNameArray(index), “$”+totalTicketPriceArray(index))
End For
Pseudo Code Solutions_1
// close the file
Close file
End Module
// This module helps to determine the cost of the ticket
Module getCost ( noOfTickets, price)
// compute the cost of the ticket
cost = noOfTickets*price
// return the cost of the ticket
return cost
End Module
Module Main
// create array to store the family names
Create String Array named familyNameArray
// create array to store the ticket price
Create String Array named totalTicketPriceArray
Set index to 0
// open the file “Family_Info.xlsx” to read its contents
file = Open File named “Family_Info.xlsx” in Read Mode
// read the header line
Read header Line
// read the file line by line until EOF
While file not EOF
// read the line and split the data by comma
data=Read Line and split
// determine the name of the family name
familyNameArray [index] = data[0]
// determine the cost of adult tickets
Call getCost(data[1],37) adultTicketCost
// determine the cost of teenager tickets
Call getCost(data[2],25) teenagerTicketCost
// determine the cost of children tickets
Call getCost(data[3],18) childrenTicketCost
//calculate the cost of all adult, teenager and childer tickets
Pseudo Code Solutions_2

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
IPO Chart: Input Phone Number Process
|5
|626
|376

Thinking Technology and Design - Program Algorithms and Pseudocode
|6
|694
|181

Target Costing in Food Manufacturing Industry
|12
|4949
|42