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
Whitepunk [10]
3 years ago
8

5. Create a variety of test cases focusing on the sorting algorithm, such as the final element is the smallest, the entire set i

s already sorted, etc. Explain the purpose of each test case, and check your code against each of those cases
Computers and Technology
1 answer:
andrew11 [14]3 years ago
7 0

Answer:

// C code

// This code will compute the values of the sales ticket sales for concerts

#include <stdio.h>

#define MAXN 100 // max characters in a group/concert name

#define MAXG 50 // max concerts/groups

#define MAXC 3 //max categories

char group [MAXG][MAXN];

int fans [MAXG][MAXC];

float prices [MAXC];

float sales [MAXG];

int count = 0;

void printArray () {

printf ("%15s%5s%5s%5s%10s\n",

"Concert", "s1", "s2", "s3","Sales");

for (int i = 0; i < count; i++) {

printf ("%15s", group [i]);

for (int j = 0; j < MAXC; j++) {

printf ("%5d", fans[i][j]);

} // end for each category

printf ("%10.2f\n", sales [i]);

} // end for each group

} // end function printArray

void computeSales () {

for (int i = 0; i < count; i++) {

sales [i] = 0;

for (int j = 0; j < MAXC; j++) {

sales [i] += prices [j] * fans [i][j];

} // end for each category

} // end for each group

} // end function computeSales

// ***** totalSales ****

void totalSales()

{

float tsales;

for(int i = 0; i <= MAXC; i++){

tsales += sales [i];

}

printf("\n\t\tThe total sales are: $%.2f\n",tsales);

}

// ***********************************

void switchRows (int m, int n) {

char tc;

int ti;

float v;

// printf ("Switching %d with %d\n", m, n);

for (int i = 0; i < MAXN; i++) {

tc = group [m][i];

group [m][i] = group [n][i];

group [n][i] = tc;

} // end for each character in a group name

for (int i = 0; i < MAXC; i++) {

ti = fans [m][i];

fans [m][i] = fans [n][i];

fans [n][i] = ti;

} // end for each fan category

v = sales [m];

sales [m] = sales [n];

sales [n] = v;

} // end switch

int findMinSales (int m) {

float min = sales [m];

int target = m;

for (int i = m+1; i < count; i++)

if (sales [i] < min) {

min = sales [i];

target = i;

} // end new max found

return target;

} // end function findMinSales

void sortBySales () {

int target;

for (int i = 0; i < count; i++) {

target = findMinSales (i);

if (target > i)

switchRows (i, target);

} // for each concert

} // end function sortBySales

//**********sort by fans*************

int minFans (int b) {

float min = fans [b][0];

int target = b;

for (int i = b; i < count; i++)

if (fans [i][0] < min) {

min = fans [i][0];

target = i;

} // end new max found

return target;

}

void sortByFans () {

int target = 0;

//int result;

 

for (int i = 0; i < count; i++) {

target = minFans(i);

if (target > i)

//result = target;    

switchRows (i,target);

 

}

}

//********************************

void getData () {

// for (int i = 0; i < MAXG; i++) sales [i] = 0;

printf ("\nEnter ticket prices in each of %d cateogories: ", MAXC);

for (int i = 0; i < MAXC; i++)

scanf ("%f", &prices [i]);

printf ("-- Enter group and fans in %d categories\n", MAXC);

printf (" . to finish entries:\n");

for (int i = 0; i < MAXG; i++) {

scanf ("%s", group[i]);

if (group [i][0] == '.')

break;

count++;

for (int j = 0; j < MAXC; j++)

scanf ("%d", &fans[i][j]);

} // end for each group

} // end function getData

int main(void) {

getData ();

computeSales ();

printArray ();

printf ("\n --- Sorted sales ---\n");

sortBySales ();

printArray ();

totalSales ();

printf("--- sorted by fans ---\n");

sortByFans ();

printArray ();

totalSales ();

printf("\t\t ... Bye ...\n");

return 0;

}

You might be interested in
Disconnecting or making the equipment safe involves the removal of all energy sources and is known as _____________. A) Isolatio
Ray Of Light [21]

Isolation. Also is known as Lockout-Tagout. I hope this helps.

5 0
3 years ago
Read 2 more answers
In QBasic, create a number guessing challenge. Your program should generate a random number from 1-
Sergio039 [100]

Answer:

yes

Explanation:

6 0
3 years ago
How will advertising and communications change as technology improves?????? HELP PLEASE :0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
drek231 [11]

Technology changes advertising and communications by increasing the outreach of people that will get the message, and increasing the speed at which they get the message. Which in turn makes the advertising more relevent because they can release more product to a wider audience during a specific time period.


6 0
3 years ago
A study guide can be created
choli [55]

Answer:

C, Both of these.

Explanation:

You can take notes either way. It's just your preference. Hope this helps :)

7 0
3 years ago
Read 2 more answers
You are the IT administrator for a small corporate network. You have installed the Windows Server 2016 operating system on a ser
Elan Coil [88]

Answer:

In this lab, you perform the following tasks:

• On Disk 1, create a mirrored volume of the System (C:) volume to add fault tolerance.

• Using Disk 2, Disk 3, and Disk 4, create a RAID 5 volume that provides both fault tolerance and improved performance using the following settings:

o Volume size: 2 TB

o Drive letter: R

o Format: NTFS

o Volume label: Data

Complete this lab as follows:

1. Mirror an existing volume as follows:

a. Right-click Start and select Disk Management.

b. Click OK to initialize new disks.

c. Maximize the Disk Management window to better view the volumes.

d. Right-click the System (C:) volume and select Add Mirror.

e. Select Disk 1 that will be used for the mirrored copy.

f. Select Add Mirror.

g. Click Yes to convert the basic disk to a dynamic disk.

2. Create a RAID 5 volume as follows:

a. In Disk Management, right-click a disk with free space and select New RAID 5 Volume.

b. Click Next.

c. Under Available, holding down the Ctrl key, select Disk 3 and Disk 4 to be part of the new volume with Disk 2.

d. Select Add.

e. Click Next.

f. From the drive letter drop-down dialog, select R; then click Next.

g. Make sure that NTFS is selected as the file system.

h. In the Volume label field, enter Data.

i. Select Next.

j. Click Finish to create the volume.

k. Click Yes to convert the basic disk to a dynamic disk.

Explanation:

5 0
3 years ago
Other questions:
  • True or false? It is just too challenging to have different password for every
    12·1 answer
  • Which statement is true of Web-based electronic data interchange (Open EDI)? a. It consists of international agreements on priva
    7·1 answer
  • When you set the position property for a block element to fixed, the element
    5·1 answer
  • Which type of microphone uses two metal plates?
    7·1 answer
  • What are some good electronics that I can buy on Amazon?
    14·1 answer
  • A technician has just installed a video card in a PC. The video card is not working, althoughit was working fine on the test ben
    6·1 answer
  • TWO MINUTES LEFT<br> ________ __________ is the physical arrangement of devices on a network.
    9·1 answer
  • Write if true or false
    12·1 answer
  • Decision support systems help managers use structured data to identify problems and find solutions to business-related problems.
    10·1 answer
  • you have been using snmp on your network for monitoring and management. you are concerned about the security of this configurati
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!