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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education