logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Create an array to hold all of the parts information (including an additional column for the total prices) using the malloc

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Need to finish the work

 

Objective:

Students will display their knowledge of sorting algorithms and memory management functions

(and previous course topics) in programming using a real-world example.

Problem:

You are the financial manager of a robot development design team on campus. Recently, the

team sent you requests for certain parts to complete their design prototype. These part orders

have been pooled into a single file, which contains the total number of different parts to be

ordered on the first line. On subsequent lines, the following information is given for each

different part: the part serial number, the price of ordering a single unit of that part, and the

number of units to be ordered. This information is provided in that order, separated by spaces. A

visualization of the file layout is shown below.

2

4913 26.41 9

8057 13.70 14

As the financial manager, you want to analyze the total price of ordering all the different parts to

make sure your team stays on budget. To do this, you have decided to calculate the total price of

ordering all units for each part, reorganize them in increasing total price, and store the sorted list

in its own file for convenient viewing. (Hint: the total price can be determined by multiplying the

price of a single part unit by the number of units to order.) This new file will have a title on the

first line displaying what each column represents. The subsequent lines will provide the same

information as in the original file, but containing the total price value for that part. A visualization

of this layout is shown below.

Serial / Price / Units / Total

8057 13.70 14 191.80

4913 26.41 9 238.41

For this assignment, you will be both outputting the final parts list to the console to review

immediately, as well as saving it to a file for later reference!

Instructions:

Write a program in C to performing the following tasks:

• Open and read the first line of the file “parts.txt” to get the number of different parts.

o For this to work correctly in Mimir, the code you write should just use the

file name to open the file, and not the full path to its location (i.e. the file

should be in the same folder as the executable file)

• Create an array to hold all of the parts information (including an additional column for

the total prices) using the malloc

• Read all the parts information from the file into the first three columns of your array.

• For each different part, calculate the total price of ordering all units of that part and store

that value in the fourth column of the array.

• Output the contents of your array to the console. You can use the Example Output Code

section to help you do this.

• Sort the different parts in increasing order of total order price. Make sure you move all

row elements when performing swaps!

• Output the contents of your array to the console using the format shown above

(including the heading line).

• Store the finished array in a new file named “orders.txt”, with the format shown above.

• Use the free function to free the memory associated with your parts array.

Comments are mandatory for this assignment. Add comments as necessary for important parts of

your code, such as memory allocation, repetition or selection structures, or function calls to

explain what the program is doing.

Both your output and your “orders.txt” file must match the sample output below, including

all text and formatting; ; otherwise, the autograding software will not be able to grade your

assignment, which may affect your mark.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

837 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

873 Answers

Hire Me
expert
Husnain SaeedComputer science

915 Answers

Hire Me
expert
Atharva PatilComputer science

655 Answers

Hire Me

Get Free Quote!

439 Experts Online