Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

CS 159 – Weekly Assessment 2 – Spring 2020

CS 159 – Weekly Assessment 2 – Spring 2020

CS 159 – Weekly Assessment 2 – Spring 2020

Upload the “.c” file on Moodle through the Weekly Assessment 2 submission link.

Part 1: Weekly Assessment for class.

Part 2: Weekly Assessment for lab.

Weekly Assessment 2 (Weight 15%) should be done individually.

Deadline: 12/05/2020

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 cylinder, and the width. Note that

you cannot use nested loops in the program. We consider in the program three one-dimensional

arrays named as follows:

1. door: An array to save the number of doors for each car.

2. cylinder: An array to save the number of the cylinders of each car.

3. width: An array to save the car width.

The size of all arrays used in the program is 5. Consider the constant SIZE with value equal to 5.

The values of the arrays’ elements (door[i], cylinder[i] and width[i]) represent the car’s

information with car ID’s equal to the value of the index “i”.

Part 1:

1. Write a function M_PrintArray_04 that 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 as shown in the example below. (15 points) Example: If the array contains: [2, 4, 1, -1, -1], the function should print the following: The array’s elements: 2 4 1

2. Write a function M_Max_width_04 that takes three arrays (door, cylinder and width) as formal parameters and then prints the cars’ information of the longest car(s). It could be more than one car. For example, if we have 3 cars with widths 2.2 (id =0), 2 (id =1) and 2.2 (id =2), this function should print the values of 2 cars with id = 0 and id =2. (20 points)

3. Write a function M_Count_doors_04 that takes a one dimensional array (door) as formal parameter and then calculates and returns the number of occurrence of the value 3 in the array door. (10 points)

Part 2:

4. Write a function M_DrawRectangle_04 that displays the below rectangle (row = 5 and column = 10) horizontally centered in the screen by using a for loop as shown in figure 1. (25 points)

P a g e | 2

Figure 1 Rectangle horizontally centered in the screen

5. Write a main function that does the following: (30 points) – Define and initialize three one-dimensional arrays named door, cylinder and width with the

value -1. The value -1 means that the agency didn’t have any car yet. – Prompt the user to enter all cars’ information (door, cylinder and width) until user enter 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 the reading from the standard input.

– Display the sample output below by calling the following functions: M_PrintArray_04, M_Min_width_04, M_Count_cylinder_04 and M_DrawRectangle_04.

Sample Output:

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Blackboard Experts only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Blackboard Experts are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Blackboard Experts is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Blackboard Experts, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.