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.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
DOCUMENTATION 1.Solution: IPO Chart InputProcessingOutput PhoneNumber includingCountry 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
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
// 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
totalTicketPriceArray[index]=adultTicketCost+teenagerTicketCost+ childrenTicketCost // increment index by 1 index += 1 End While // Call WriteToFile function to write the content of family name and total ticket price Call WriteToFile (familyNameArray, totalTicketPriceArray) // close the file Close file End Module 4.Solution: Pseudo Code: // This module is used to check if the temperature value is valid Module isValidTemperature(temperature) // Check if temperature is in specified range -20 and 55 If (temperature < -20 || temperature > 55) Return False Return True End Module // This module is used to check if the humidity value is valid Module isValidHumidity (humidity) // Check if humidity is positive integer equal or less than 100 If (humidity <= 0 || humidity > 100) Return False Return True End Module // This module determines the chance of rain based on temperature and humidity value Module determineChanceOfRain (temperature, humidity) // Checks if the temperature is Less than 0 and Humidity is Less than 20% If (temperature < 0 and humidity < 20) Write “Chance of Rain: 0%” // Checks if the temperature is Between 0 and 15 and Humidity is Between 20% to 40% Else If (temperature >=0 and temperature <=15 and humidity >= 20 and humidity <= 40) Write “Chance of Rain: 20%” // Checks if the temperature is Between 15 and 30 and Humidity is Between 40% to 60%
Else If (temperature >=15 and temperature <=30 and humidity >= 40 and humidity <= 60) Write “Chance of Rain: 50%” // Checks if the temperature is More than 30 and Humidity is Between 60% to 80% Else If (temperature > 30 and humidity >= 60 and humidity <= 80) Write “Chance of Rain: 75%” // Checks if the temperature is More than 30 and Humidity is More than 80% Else If (temperature > 30 and humidity > 80) Write “Chance of Rain: 90%” End Module Module main() // Get temperature in Celsius from User Read temperature // Get humidity from User Read humidity // Check if the temperature is valid by calling the Module isValidTemperature Call isValidTemperature(temperature)isValidTemp // If the temperature is not valid If (isValidTemp is False) { // Display Temperature Error message Write “Temperature should be between -20 and 55” } Else { // Check if the humidity is valid by calling the Module isValidHumid Call isValidHumidity (humidity)isValidHumid // if the humidity is not valid If (isValidHumid is False) { // Display Humidity Error message Write “Humidity should be a positive integer equal or less than 100” } Else { // Call the module determineChanceOfRain to determine chance of rain in percentage
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser