a.)For this program specification, I only want you to outline the code . No repe
ID: 3920434 • Letter: A
Question
a.)For this program specification, I only want you to outline the code. No repeating the question in a English-class-style flowery paragraph of lame. No C++. These are the outline comments you put in the code to organize yourself for a large program. You can't just say "Figure out if they are right". You need enough detail for my dumb little brother to write this.
Write a program that helps a library calculate how much shelf space they need. You'll ask the user for the name of a book over and over. When they type in "XXXXXX" as the name of the book so they can quit, print out the number of books that started with each letter in the English alphabet. You don't need to store the book names - we are just calculating shelf space.
There is one little complication. The government has banned all books with the word "badger" in the title. If the user enters one, don't count it and print a message warning them not to be naughty.
b.)Write out just the "declare data" portion of your program for the library book question. Make sure to include every variable you think you'd need for the whole program.
Explanation / Answer
Code outline for the library book system
Variables:
Name: title
type : String
Purpose: to store the title of the book input by the user
Name: count
type : Integer
Purpose: to store the number of the books input by the user
Name: alphabetlist
type : array of integers
Purpose: to store number of book titles starting with an alphabet.So this
array is of size 26.Each entry corresponds to one letter in the alphabet
0 index represent a, 1 index represent b and so forth....
Code outline // Assuming titles will be input in lowercase letters
count = 0
loop i : 0 to 25
alphabetlistcount[i] = 0
loop:
title = Input book title
if titele not equal to "XXXXXX"
if title does not contain "badger"
count = count + 1
alphabetlist[ title[0] - 97] = alphabetlist[ title[0] - 97] + 1 // 97 is the ascii value of a and 122 is the ascii value of z
else
Display "Title not accepted as it contains "badger""
else
break from the loop
Display "Total number of books is count
loop: i : 97 to 122
Display "Number of books starting with letter ascii charcter(i) is alphabetlistcount[i-97]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.