7. a. The Daily Trumpet newspaper accepts classified advertisements in 15 categories such as Apartments for Rent and Pets for Sale. Develop the logic for a program that accepts classified advertising data, including a category code (an integer 1 through 15) and the number of words in the ad. Store these values in parallel arrays. Then sort the arrays so that records are sorted in ascending order by category. The output lists each category number, the number of ads in the category, and the total number of words in the ads in the category.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

I need a program written in C++, please. The assignment question and pseudocode are provided in the attachments. Again, with all the information given, I need a completed program made in C++, thank you!

a. The Daily Trumpet newspaper accepts classified advertisements in
15 categories such as Apartments for Rent and Pets for Sale. Develop the logic
for a program that accepts classified advertising data, including a category
code (an integer 1 through 15) and the number of words in the ad. Store
these values in parallel arrays. Then sort the arrays so that records are sorted
in ascending order by category. The output lists each category number, the
number of ads in the category, and the total number of words in the ads in the
7.
category.
Transcribed Image Text:a. The Daily Trumpet newspaper accepts classified advertisements in 15 categories such as Apartments for Rent and Pets for Sale. Develop the logic for a program that accepts classified advertising data, including a category code (an integer 1 through 15) and the number of words in the ad. Store these values in parallel arrays. Then sort the arrays so that records are sorted in ascending order by category. The output lists each category number, the number of ads in the category, and the total number of words in the ads in the 7. category.
// Pseudocode PLD Chapter 8 #7a pg. 366
// Start
//
Declarations
num MAXADS = 100
num adcatcode [ MAXADS]
//
//
num adwords [MAXADS]
//
num curCode
//
num numads
//
num i
//
num j
num k
num subtotal
num temp
output "Please enter the number of ads:
input numads
if ( (numads > 0) and (numads <= MAXADS))
for i = 0 to numads - 1
//
//
//
//
//
output "Please enter Advertisement Category Code
(1 -
15):
input adcatcode [i]
output "Please enter number of words for the
//
//
advertisement: "
//
input adwords [1]
//
endfor
for i = 0 to numads - 2
for j = 0 to numads
if (adcatcode [j] > adcatcode [j+1])
//
//
- 2
//
//
temp = adcatcode [j]
adcatcode [j] = adcatcode [j+1]
adcatcode [j+1] = temp
temp = adwords [j]
adwords [j] = adwords [j+l]
adwords [j+1] = temp
//
endif
//
endfor
endfor|
//
//
output "Total Word Counts Sorted By Category Code"
//
output
"======
k = 0
while k <= numads - 1
subtotal = 0
curCode = adcatcode [k]
//
//
while ( (curCode == adcatcode [k] ) and (k <=
numads
1) )
//
subtotal = subtotal + adwords [k]
//
k = k + 1
//
endwhile
//
output "Category: ", adcatcode [k
1],
"Word
Count: ", subtotal
endwhile
//
//
else
//
output "Number adds requested less than l or is too
large; ad limit is ",
MAXADS
//
endif
// Stop
Transcribed Image Text:// Pseudocode PLD Chapter 8 #7a pg. 366 // Start // Declarations num MAXADS = 100 num adcatcode [ MAXADS] // // num adwords [MAXADS] // num curCode // num numads // num i // num j num k num subtotal num temp output "Please enter the number of ads: input numads if ( (numads > 0) and (numads <= MAXADS)) for i = 0 to numads - 1 // // // // // output "Please enter Advertisement Category Code (1 - 15): input adcatcode [i] output "Please enter number of words for the // // advertisement: " // input adwords [1] // endfor for i = 0 to numads - 2 for j = 0 to numads if (adcatcode [j] > adcatcode [j+1]) // // - 2 // // temp = adcatcode [j] adcatcode [j] = adcatcode [j+1] adcatcode [j+1] = temp temp = adwords [j] adwords [j] = adwords [j+l] adwords [j+1] = temp // endif // endfor endfor| // // output "Total Word Counts Sorted By Category Code" // output "====== k = 0 while k <= numads - 1 subtotal = 0 curCode = adcatcode [k] // // while ( (curCode == adcatcode [k] ) and (k <= numads 1) ) // subtotal = subtotal + adwords [k] // k = k + 1 // endwhile // output "Category: ", adcatcode [k 1], "Word Count: ", subtotal endwhile // // else // output "Number adds requested less than l or is too large; ad limit is ", MAXADS // endif // Stop
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning