Array and Strings – Arithmetic – Problem #9
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a program, which reads unit prices of N (to be read) items in INR in an array of real number. The program also reads another array of size N, where it stores the number of units to be procured for the items maintaining the same order of price list. It should print the following: (i) Maximum unit price from the list, (ii) total cost of procurement (iii) total number of items procured, and (iv) the item for which the maximum amount of INR is spent. For example, for 3 items (N=3), the unit price list (in INR) and the number of items to be procured are given as follows: Unit Price List: 1000.00, 1200.00, 800.00 Number of items to be procured: 5, 3, 0 For the above input the program prints the following: (i) Maximum unit price: Rs. 1200.00 (ii) Total cost of procurement: Rs. 8600.00 (iii) Total number of items procured: 8 (iv) The item for which the maximum expenditure is made: Item 1. Provide output for the following input data set. Assume that the sequence of unit prices preserve the order of number of items procured: (i) N=5 Unit Price List: 5.0, 12.54, 50.65, 27.85, 19.34 Number of items to be procured: 10, 32, 0, 25, 18 (ii) N=10 Unit Price List: 15.0, 102.65, 77.25, 18.34, 19.85, 8.25, 32.83, 125.00, 45.34, 16.86 Number of items to be procured: 15, 25, 20, 0, 10, 12, 0, 8, 35, 30