1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Jlenok [28]
3 years ago
9

The Daily Trumpet newspaper accepts classified advertisements in 15 categories such as Apartments for Rent and Pets for Sale. De

velop 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. Thank you.
// 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

Computers and Technology
1 answer:
PtichkaEL [24]3 years ago
7 0

Answer:

see explaination

Explanation:

#include<iostream>

using namespace std;

#define MAXDAS 100

int main()

{

//int MAXADS = 100;

int adcatcode[MAXDAS];

int adwords[MAXDAS];

int curCode;

int numads;

int i,j,k;

int subtotal;

int temp;

cout<<"Please enter the number of ads: ";

cin>>numads;

if((numads > 0) and (numads <= MAXDAS))

{

for (i = 0;i<numads;i++)

{

cout<<"Please enter Advertisement Category Code (1 - 15): ";

cin>>adcatcode[i];

cout<<"Please enter number of words for the advertisement: ";

cin>>adwords[i];

}

for (i=0;i<numads-1;i++)

{

for (j = 0;j<numads-1;j++)

{

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;

}

}

}

cout<<"Total Word Counts Sorted By Category Code"<<endl;

cout<<"========================================="<<endl;

k = 0;

while(k<=numads-1)

{

subtotal = 0;

curCode = adcatcode[k];

while ( (curCode == adcatcode[k])&& (k <= numads - 1) )

{

subtotal = subtotal + adwords[k];

k = k + 1;

}

cout<<"Category: "<<adcatcode[k - 1]<<" "<<"Word Count: "<<subtotal<<endl;

}

}

else

{

cout<<"Number adds requested less than 1 or is too large; ad limit is :"<<MAXDAS;

}

return 0;

}

See attachment for output

You might be interested in
Where are some places that cyberbullying occurs? check all that apply
antiseptic1488 [7]

Answer:

social media like  snap chat twitter  and face book .it can even happen over email.or in school chats.

Explanation:

5 0
3 years ago
Read 2 more answers
What is the maximum number of columns in a spreadsheet that you can sort in one instance in software like OpenOffice Calc?
MakcuM [25]
The correct answer is D
6 0
3 years ago
Read 2 more answers
Which of the following is among the ComScore Ad Metrix Reports?
IceJOKER [234]
I think it is d but not exactly sure
6 0
2 years ago
Computers automatically name the main hard drive the_____ drive?
telo118 [61]

Answer:

Im not entirely sure but I think this is disk drive

Explanation:

6 0
3 years ago
Use a _____ to safeguard computer systems from voltage fluctuations.
liq [111]

Answer.

1.Surge protection board

2.Uninterrupted Power Supply (UPS)


Explanation

A surge protection board is designed to protect equipment against a power surge or over voltage in power supply.A UPS provides back up power in occasions of power outage.In most events of power cut,UPS units only allow a person to save the work and perform a controlled shutting down of a computer.

4 0
3 years ago
Other questions:
  • What does % find on edhesive??
    14·1 answer
  • TLO 06 Active Directory Domain and Trusts tool is used to move servers between site in an AD Infrastructure.a. Trueb. False
    14·1 answer
  • &gt;&gt;&gt; import math &gt;&gt;&gt; print(math.Pi) 3.141592653589793 &gt;&gt;&gt; def print_volume(): print ("What is the radi
    12·1 answer
  • PLEASE HELP ASAP!!
    11·2 answers
  • relational integrity constraints are rules that enforce basic and fundamental information-based constraints. True or False
    9·1 answer
  • According to chronology, arrange the steps that you need to take during the installation of a ram stick?
    13·1 answer
  • Which of the following is not a language commonly used for web programming?
    8·2 answers
  • Select the correct answer.
    9·1 answer
  • When computer network are joined together they form a bigger network called the​
    5·1 answer
  • The pinky finger on the right hand types _____.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!