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

1. Write a C+program to process car sales data. The input file has 10 lines; eac

ID: 3589573 • Letter: 1

Question

1. Write a C+program to process car sales data. The input file has 10 lines; each ine has the last name of a salesperson, followed by the number of cars that person sold this month Input: The program calls an input function to read the data into parallel arrays. An array names of type string holds the last names; an array cars of type int holds the number of cars sold. For any index k between O and 9, the number of cars sold by names[k) is cars[k] Processing and Output : The program determines and outputs the total number of cars sold this month. Using the indexLargestElement function, the program finds the largest number of cars sold by one person, and outputs that salesperson's name and number of cars sold. 2. Selection Sort Use the selection sort algorithm to arrange the following list in ascending order: 12, 50, 68, 30, 46, 5, 92. 10, 38 Write a C++program that declares an array list and initializes it to these 9 elements. The program calls the selection sort function, which is modified to output the list after each iteration of the outer for loop, so you can compare the results with those obtained by hand

Explanation / Answer

#include<iostream>

#include<string>

using namespace std;

class sales{

string names[10];

int cars[10];

public:

void get_input()

{ int totalcars=0,i;

cout<<"Enter the details ";

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

{

cin>>names[i];

cin>>cars[i];

totalcars+=cars[i];

}

cout<<"total number of cars sold in a month="<<totalcars;

}

void find_largest()

{

sales A;

int max=0,i;

for(i=1;i<10;i++)

if(cars[i]>cars[max])

max=i;

cout<<" Largest sales details in month ";

cout<<names[max]<<" "<<cars[max];

}

};

int main()

{

sales A;

A.get_input();

A.find_largest();

return 0;

}

// Second Question............

#include<iostream>
#include<string>
using namespace std;

class Selection{

int a[9];

public:

Selection()

{

int i;

int b[9]={12,50,68,30,46,5,92,10,38};

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

a[i]=b[i];

}

void swap(int i, int j)

{

int temp;

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

void sort()

{

int i,j, max;

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

{

max=i;

for(j=i+1;j<9;j++)

if(a[j]<a[max])

max=j;

swap(i,max);

for(j=0;j<9;j++)

cout<<a[j]<<" ";

cout<<" ";

}

}

};

int main()

{

Selection S;

S.sort();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote