Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the code in C++ language. The Daily Trumpet newspaper accepts classified a

ID: 3686029 • Letter: W

Question

Write the code in C++ language. 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 an ad. Store these values in parallel arrays. Then sort the arrays so that the 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. Using the following pseudocode.

// 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[i]

//         endfor

//         for i = 0 to numads - 2

//           for j = 0 to numads - 2

//             if (adcatcode[j] > adcatcode[j+1])

//               temp = adcatcode[j]

//               adcatcode[j] = adcatcode[j+1]            

//               adcatcode[j+1] = temp

//               temp = adwords[j]

//               adwords[j] = adwords[j+1]

//               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 1 or is too large; ad limit is ", MAXADS

//     endif

// Stop

Explanation / Answer

#include<iostream>

using namespace std;

//sort function
void selection_sort(int [], int [], int n);
void print(int [], int [], int n);

int main(){
  
   int MAXADS = 100;
  
   int adcatcode[MAXADS];
   int adwords[MAXADS];%