Consider the following tasks below:
Task: a solution is required which prompts the user to enter a person’s name their gender and birth year. The solution should output a message stating the The person’s name, wheather they are an adult, teenager or child, as well as their gender.
E.g, If the user enters Khan Smith, male, 2000; the solution would output :
Khan Smith is an male adult who will be 21 years old this year.
or a similar message.
This solution was created in Flowgorithm (Download files here):
Solution in Pseudocode
Start // Here we initialize variables for first use.... personName = "Unknown" sex = "Unknown" currentYear = 2021 birthYear = -9999 // end initialization. // Get the data from the user.... output "Please enter the person's name" input personName output "Please enter the person's Year of Birth" input birthYear output "Please enter the person's sex, either M for male, or F for Female" input sex // start to process data... // Determine the sex form the entered character.... if sex = "M" then sex = " is a male " else sex = " is a female " end If age = currentYear - birthYear if age > 19 then personType = " adult " else if age > 12 then personType = " teenager " else personType = " child " end If end If result = personName + sex + personType + "who will be " + age + " years in " + currentYear output result output "thanks for using my program!" // © 2021 Vedesh Kungebeharry. All rights reserved. End
© 2021 Vedesh Kungebeharry. All rights reserved.