Write a C program to keep records and perform statistical analysis for a car sales agency. The information of each car contains the number of the doors, the year, and the price. Note that you cannot use nested loops in the program. The expected output should contain your name, your CS 159 section number and your student ID as shown in the sample output. In the program, materials covered in the class should only be used. In the program, constant statement, global variables, nested loop, and else statement cannot be used. The main function should run successfully with different scenarios. We consider in the program three one-dimensional arrays named as follows:
1. An array to save the number of doors for each car. The name of the array is “DoorArray” followed by the value of your student ID. If your student ID is 42357, the array name will be DoorArray _42357. (2 points)
2. An array to save the car year. The name of the array is “YearArray” followed by the value of your student ID. If your student ID is 42357, the array name will be YearArray _42357. (2 points)
3. An array to save the car price. The name of the array is “PriceArray” followed by the value of your student ID. If your student ID is 42357, the array name will be PriceArray _42357. (2 points)
The size of all arrays used in the program is SIZE. The value of SIZE is equal to your section number plus one. If your section is O10, the value of SIZE should be 11 (10+1).
The values of the arrays’ elements (DoorArray _42357[i], YearArray_42357[i] and PriceArray_42357[i]) represent the car’s information with car ID’s equal to the value of the index “i”.
1. Define a first function that performs the following:
• The name of the function is “PrintOfArray” followed by the value of your section number and your student ID number. For example, if your section number is O10 and your student ID is 42357, the name of this function should be PrintOfArray_O10_42357. (2 points)
• Print on the screen, the function name following by your student ID number and your section number. For example, if your section number = O10 and ID = 42357, the program should print: (3 points)
PrintOfArray_O10_42357 is created by student ID = 42357- section O10.
• Takes an array of integers with size equal to SIZE and prints all array’s elements horizontally centered in the screen. This function should not print elements with value equal to -1. For example, if the array contains [2, 3, 4, -1, -1, -1, -1, -1, 5, -1], the function should print the following: (5 points)
The array’s elements: 2 3 4 5
• Defines a local array of integer named RandomNumbers with size equal to M. The value of M is equal to the sum of digits of your student ID. For example, if your student ID is 42357, the value of M is 21 (4+2+3+5+7 = 21). Initialize the array RandomNumbers with random value from 3 to 17. The function should return the sum of elements in array RandomNumbers. (10 points)
2. Define a second function that performs the following:
• The name of the function is “MinimumPrice” followed by the value of your section number and your student ID number. For example, if your section number is O10 and your student ID is 42357, the name of this function should be MinimumPrice _O10_42357. (2 points)
• The function Takes 3 arrays that represent the door, year, and price of cars as formal parameters.
• Defines a local string variable named ST_INFO with size equal to N. The value of N is equal to the sum of your student ID number and your section number. For example, If your section is O10 and your student ID number is 42357, the value of N is 42367 (42357 + 10 = 42367). Initialize the string variable with your name, your student ID and your section number. For example, if your name is “xxx yyy”, your ID is 42357and your section is O10, the value of ST_INFO will be “xxx_yyy_section_O10_ID_42357”. The function then print the name of the function and the value of string variable ST_INFO as below: (5 points)
“Function MinPrice_O10_42357 is created by student xxx_yyy_section_O10_ID_42357”.
• Prints the cars’ information of the cheapest car(s). It could be more than one car. For example, if we have 3 cars with prices 3000 (id =0), 4000(id =1) and 3000 (id =2), this function should print the values of 2 cars with id = 0 and id =2. (13 points)
3. Define a third function that performs the following:
• The name of the function is “YearInfo” followed by the value of your section number and your student ID number. If your section is O10 and your student ID number is 42357. For example, if your section number is O10 and your student ID is 42357, the name of this function should be YearInfo _O10_42357. (2 points)
• Takes 3 arrays that represent the door, year, and price of cars as formal parameters.
• Defines two local integer variables named OddN and EvenN. You cannot use a loop in this part. The value of OddN is equal to the sum of all odd digit of your student ID number. Initialize EvenN with the sum of all even digit number of your student ID number. For example, if your student ID is 42357, the value of OddN will be 15 (3+5+7) and the value of EvenN will be 6 (4 + 2 = 6). The function should then print the value of OddN and EvenN as below: (5 points)
“Function InfoYear_O10_42357 – Sum of odd digit OddN = 15 and sum of even digit EvenN = 6”.
• Calculates and prints the average price of a car in 2019. (8 points)
• Counts and return the number of mini-car in 2022. A mini-car is a car with two doors. (5 points)
4. Define a fourth function that performs the following:
• The name of the function is “DrawSC” followed by the value of your section number and your student ID number. If your section is O10 and your student ID number is 42357. For example, if your section number is O10 and your student ID is 42357, the name of this function should be DrawSC _O10_42357. (2 points)
• Prints in the screen 5 lines that contains only the character “hash symbol”. The number of “#” to be printed per line depends on your students ID number. If your student ID is 42357, the first line should contain 4 characters “hash symbol”, the second line should contain 2 characters “hash symbol”, the third line should contain 3 character “hash symbol”, the fourth line should contains 5 character “hash symbol” and the fifth line should contains 7 character “hash symbol”. You can use only printf instruction in this part. (3 points)
• Displays the below rectangle (row = 4 and column = 7) horizontally centered in the screen by using a for loop as shown in Figure 1. (5 points)
Figure 1 Horizontally centered rectangle in the screen
5. Write a main function to do the following:
- Define and initialize three one-dimensional arrays that represent door, year, and price with the value -1. The value -1 means that the agency does not have any car yet. (3 points)
- Print your section number, your last name, and your student ID on the screen. For example, if your last name = yyy, section number = O10 and ID = 42357, the program should print: (2 points)
“Main Function has been code by:
o Student: yyy
o Section: O10
o ID : 42357”.
- Prompt the user to enter all cars’ information (door, year, and price) until user enters EOF. When the user enters EOF, the main function should stop reading and assign -1 to the remaining elements of all arrays. Note that the user should enter 3 values for each car. If the user enters successfully one or two values terminated by EOF for a car, the program should assign -1 to all elements of this car and stop reading from the standard input. (8 points)
- Display the below sample output by calling the above four functions. (7 points)
6. The program should adhere the following requirements:
• The name of the .C file is equal to your student ID. For example, if your student ID = 47305, the name of the file will be "47305.c". (2 points)
• Write your first name, your last name, the course code CS159, your section number and your ID as comments at the top of the code as shown below: (2 points).
If your name is xxx yyy, your ID is 47305 and your section is O10, comments should be:
/*
Page 5 of 5
This program is created by:
a- Student name= xxx yyy
b- Id = 47305
c- Section O10
d- Course code: CS 159
*/
//first function
void PrintOfArray_010_47364(int integers[11]){
printf("PrintOfArray_010_47364 is created by student ID=47364_section_010\n");
int iterator;
int input;
for(iterator=0;iterator<11;iterator++){
printf("Enter array element no %d:",iterator);
scanf("%d",&input);
//add user input to array integers
integers[iterator]=input;
}
//print array elements and if we have negatives of -1
printf("The array elements:");
for(iterator=0;iterator<11;iterator++){
int foundelemnt=integers[iterator];
if(foundelemnt !=-1){ //if array element not -1
printf("%d\t",foundelemnt); // print the element
}
}
printf("\n");
//array RandomNumbers
int RandomNumbers[24];
int p,y,sum_of_elements=0;
for(p=3;p<=17;p++){
for(y=0;y<24;y++){
RandomNumbers[y]=rand();
}
}
//access elements of RandomNumbers
int t,RandomNumber;
for(t=0;t<24;t++){
RandomNumbers[t]=RandomNumber;
sum_of_elements=sum_of_elements+RandomNumber;
}
printf("Sum of elements in array is %d\n",sum_of_elements);
}
//second function
void MinimunPrice_010_47364(int DoorArray_47364[11],int YearArray_47364[11],int PriceArray_47364[11]){
char ST_INFO[47374]="Habeeb bin Jamea_section_010_ID_47364";
printf("Function MinPrice_010_47364 is created by %s\n",ST_INFO);
int counter;
int minimum=PriceArray_47364[0];
for(counter=0;counter<11;counter++){
if(PriceArray_47364[counter]
minimum=PriceArray_47364[counter];
}
}
printf("Car with minimum price is ID %d and price is:%d\n",counter,minimum);
}
//third function
void YearInfo_010_47364(int DoorArray_47364[11],int YearArray_47364[11],int PriceArray_47364[11]){
int OddN=10;
int EvenN=14;
printf("Function YearInfo_010_47364-Sum of odd digit OddN=%d and sum of even digit EvenN=%d\n",OddN,EvenN);
int f,element,yearcar,count=0,cardoor,count_mini_car=0;
float sumprice=0,averageprice=0;
averageprice=sumprice/count;
}
//check cars in 2022 with two doors i.e a mini-car
if(cardoor==2 && yearcar==2022){
count_mini_car++;
}
}
printf("Average price of car in 2019 is %.2f\n",averageprice);
printf("Number of mini car in 2022 is %d\n",count_mini_car);
}
//main function
int main(){
//draw rectangle on screen
DrawSC_010_47364(); //call function four
//arrays
int DoorArray_47364[11] ={-1};
int YearArray_47364[11] ={-1};
int PriceArray_47364[11] ={-1};
printf("The main function has been created by:\n Student:Habeeb bin jamea\n Section:010\n ID:47364\n");
int door,year,price,i;
char end_of_file[]="EOF";
for( i=0;i<11;i++){
printf("Enter three values for car( door, year and price):\n");
scanf("%d",&door);
DoorArray_47364[i]=door;