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

Hello, I need help writing a program in C that stores information about the make

ID: 3571281 • Letter: H

Question

Hello,

I need help writing a program in C that stores information about the makes, models and quantities of cars in inventory.

1. The program will prompt the user for the number of cars to enter first.

2. Then the program should prompt the user to type in the make and model of each car, and the quantitiy of that car in inventory.

(#2 in this format) Enter make and model of car #1, separated by a space: Porsche 911

                             Enter the quantity of car #1 in inventory: 1

3. When all data has been entered, display the list of cars and counts in the order typed in by the user (original order).

(#3 in this format) Cars By Order Entered

                             Porsche 911                        1

                             Honda Accord                    25

                             Toyota SUV                       38

                             Ford Escape                      17

                            Chevy Volt                           5

4. The list has to be then displayed in sorted order by the type of car.

(#4 Same as #3 except in sorted order)

The following selection sort code needs to be used (However, the sample sorting code is set up to sort an array of integers, I need to modify the code to sort an array of string pointers.)

5. The list is then to be redisplayed in original order again.

(Same as #3)

Here is what the sample code should look like:

int t min range int list[], int first, int last void select sort (int list[], int n) int fill temp index of min for (fill e; fill n-1; ++fill) f index of min get min range (list, fill, n-1) if (fill index of min) temp list index of min list index of min] m list[fill]; list fill] temp int get min range (int list int first, int last) int i; int index of smallest first int curr smallest curr smallest list[first] for (i first-1; i k last i++) if (list[ij curr smallest curr smallest list[i]; index of smallest i I return (index of smallest)

Explanation / Answer

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
    char name[40][100],temp[20];
    int i,j,n;
   int num[100];
   //char model[100];
    printf("How many Entries? ");
    scanf("%d",&n);


for(i=0;i<n;i++)
{
printf(" Enter Make and mode of a car #%d seperated by a space:",i);
scanf("%s ",name[i]);
//scanf(" %[^]s",name[i]);
printf(" Enter the Quantity of a car #%d in inventory:",i);
scanf("%d",num[i]);
//scanf("%s %d",name[i],&num[i]);
}
printf(" Cars in alphebetical order ");
for(i=1;i<n;i++) {
       for(j=1;j<n;j++){
               if((strcmp(name[j-1],name[j]))>0){
                   strcpy(temp,name[j-1]);
                   strcpy(name[j-1],name[j]);
                   strcpy(name[j],temp);
            }
        }
       }
for(i=0;i<n;i++){
printf(" %d)%s%d%d ",i+1,name[i],num[i]);
}
  
getch();
}

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