Details of fruits in a fruit shop are kept in a text file as shown below. Apple 4 Ambrosia 35…

Details of fruits in a fruit shop are kept in a text file as shown below.

Ambrosia 35 1.25
Cortland 40 1.10
Cameo 100 1.05
Winesap 50 1.35
Alphonso 100 1.5
Irwin 150 2.25
Sensation 200 2.0
Jaffa 200 0.5
Blood 150 0.25
Valencia 75 0.75
Asaian 100 0.35
Europian 150 0.25
Chinese 200 0.30
Yellow 300 0.05
White 400 0.15
Donut 500 0.12
Nectarines 200 0.25

So, according to the data presented above, the first fruit’s name is Apple; it has 4 different types, the first type is Ambrosia and quantity left for this type is 35 and the price for one piece is 1.25, the second type is Cortland and the quantity left for this type is 40 and price for one piece is 1.10 and so on.

Step 1:

Create a text file that contains the details of the fruits as shown in the example above. Declare an array of fruit structure shown below in main; the maximum size of the array is limited to 100.

Step 2: Create a menu-driven C program

Call a function named readFruitto read the contents of the text file into the array of fruit structure (function prototypes are given below).

fruitName: stores the name of the fruit

noOftypes: stores the number of types of fruits

typeName: stores the name of the types of fruits

quantity:stores the quantity left in the shope

price: stores price of the types

Display the menu for the user using a menu function.

The contents of the menu function should be:

Enter 1 to display the fruit database
Enter 2 to add fruits’ details into a LinkedList
Enter 3 to display LinkedList
Enter 4 to find the average price for a fruit (using LinkedList)
Enter -1 to exit the program

Option 1: displays all the contents of the array of the fruit structure on a terminal as shown on the screenshot below. Use displayArray function for this option. This displayArray function must use the array of the structure to display the details.

Option 2: adds the contents of the array into a LinkedList. Contents of the first array go to node 1 and contents of the second array go to node 2 and so on. Use the fillLinkedlistfunction for this option.

Option 3:displays all the contents of LinkedList on a terminal as shown on the screenshot below. Use printList function for this option. This displayListfunction must use the LinkedListcreated in option 2 to display the details.

Option 4:ask the user to enter a fruit name and then calculate and display the average price (precision-two decimal places) of all the types of that fruit, if there is no such fruit the program should report it back to the user. Use the findAveragepricefunction for this option. This findAveragepricefunction must use LinkedList created in option2to calculate the average. All printing happens in main for option 4.

The program should exit only when the user inputs -1.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!