Question: Your task is to complete the main method in the FruitCosts class. The program should do the following: Read the input file specified in the
Your task is to complete the main method in the FruitCosts class. The program should do the following:
Read the input file specified in the commandline argument.
Read the number of fruits from the input file.
Create two parallel arrays: one for fruit names and one for their costs.
Read the fruit names and costs from the input file and store them in the respective arrays.
Find the two fruits with the lowest costs.
Print the names and costs of the two lowestcost fruits.
Calculate and print the total cost of these two fruits.
Expected output format: Lowest cost fruit nameLowest costSecond lowest cost fruit nameSecond lowest cost Total Sum of the two lowest costs Note: In the case that multiple fruits have the same cost, maintain the order in which they appear in the input file.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
