# 57 programming logic and design 8e solutions 6 answer

• Homework Help
• 77
• 98% (246) 240 out of 246 people found this document helpful

This preview shows page 57 - 62 out of 77 pages.

##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter 6 / Exercise 19
Programming Logic and Design, Introductory
Farrell
Expert Verified
57
##### We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
The document you are viewing contains questions related to this textbook.
Chapter 6 / Exercise 19
Programming Logic and Design, Introductory
Farrell
Expert Verified
Programming Logic and Design, 8eSolutions 6-Answer: A sample solution followsFlowchart: Pseudocode:startDeclarationsnum monthnum SIZE = 12num DAYS[SIZE] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31num MONTHS[SIZE] = “January”, “February”, “March”, “April”,“May”, “June”, “July”, “August”, “September”,“October”, “November”, “December”displayDays()finishUp()stopdisplayDays()month = 0while month < SIZEoutput “Month ”, MONTHS[month], “ has ”, DAYS[month], “ days”month = month + 1endwhile58
Programming Logic and Design, 8eSolutions 6-returnfinishUp()output “End of program”returnc. Modify the months and days program to prompt the user for a month number and display the corresponding sentence in the same format as in Exercise 13b.Answer: A sample solution followsFlowchart: Pseudocode:startDeclarationsnum monthnum SIZE = 12num DAYS[SIZE] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31num MONTHS[SIZE] = “January”, “February”, “March”, “April”,“May”, “June”, “July”, “August”, “September”,“October”, “November”, “December”displayDays()finishUp()stopdisplayDays()output “Enter a month number ”input monthoutput “Month ”, MONTHS[month], “ has ”, DAYS[month], “ days”59
Programming Logic and Design, 8eSolutions 6-returnfinishUp()output “End of program”returnd. Prompt a user to enter a birth month and day, and continue to prompt until the day entered is in range for the month. Compute the day’s numeric position in the year. (For example, February 2 is day 33.) Then, using parallel arrays, find and display the traditional Zodiac sign for the date. For example, the sign for February 2 is Aquarius.Answer: A sample solution followsFlowchart: The flowchart will be similar to those shown in parts a through c.Pseudocode:startDeclarationsnum daynum monthnum numPosition = 0num xnum DAY_SIZE = 12num SIGN_SIZE = 13num DAYS[DAY_SIZE] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31string SIGNS[SIGN_SIZE] = “Capricorn”, “Aquarius“, “Pices”, “Aries”, “Taurus”, “Gemini”, “Cancer”, “Leo”,“Virgo”, “Libra”, “Scorpio”, “Sagittarius”,“Capricorn”num SIGN_RANGES[SIGN_SIZE] = 0, 21, 51, 80, 111, 142, 173, 204, 234, 267, 297, 327, 357getReady()while not eofdetailLoop()endwhilefinishUp()stopgetReady()output “Enter a month and a day >> ”input month, dayreturndetailLoop()while day < 1 OR day > DAYS[month - 1]output “Day out of range, please reenter >> ”input dayendwhilex = month – 2while x >= 0numPosition = numPosition + DAYS[x]60
Programming Logic and Design, 8eSolutions 6-x = x – 1endwhilenumPosition = numPosition + dayx = SIGN_SIZE – 1while numPosition < SIGN_RANGES[x]x = x – 1endwhileoutput “The Zodiac sign for ”, month, “/”, day, “ is ”, SIGNS[x]output “Enter a month and a day >> ”input month, dayreturnfinishUp()output “End of program”returnPerforming Maintenance1.A file named MAINTENANCE06-01.txt is included with your downloadable student files. Assume that this program is a working program in your organization and that it needs modifications as described in the comments (lines that begin with two slashes) at the beginning of the file. Your job is to alter the program to meet the new specifications.