There are 3 companies advertising the same type ofproduct. As a consumer, you ha
ID: 3616824 • Letter: T
Question
There are 3 companies advertising the same type ofproduct.
As a consumer, you have to decide which one is the best buy.Here is the
information.
You want to thicken the grass in your lawn. You look up the
advertisement from the paper. This is what each company is
advertising:- (You must use the data provided in thisquestion)
Company $/bag weight(kg)/bag purity
Admiral 3.50 10 0.6
Bosh 5.00 7.5 0.98
Carmen 4.00 7.5 0.93
Based upon the information above, write a program to decidewhich
Company’s product will give you the best for your money.To do that
You have to find $ per kg.
bestBuy($/kg ) =($/bag) / (kg/bag) / purity
(a) (3 marks) Use assignment to assign value to the variablesaccording to the table above. Your program should display the tableand add the 5th column for the Dollar $/kg value for eachcompany.
(b) (3 marks) Use if statements to decide which is the best buy(lowest $/kg value), Then use fprintf statement to print out thebest buy value as shown below.
Company Price Weight Purity Dollars$/kg
Admiral 3.50 10 0.60 0.583
Bosh 5.00 7.5 0.98 0.680
Carmen 4.00 7.5 0.93 0.573
The best buy value is 0.573
Before you write the program, you should decide
(a) How many variables are required to store data (atleast 13)
(b) What their names should be without creating confusion.
The following is only asuggestion:-
e.g. priceAdmiral, weightAdmiral,purityAdmiral and bestBuyAdmiral
(c) How do you use if statement to determine which is the bestbuy?
float bestBuy =bestBuyAdmiral;
if (bestBuyBosh < bestBuy)bestBuy = bestBuyBosh ;
if (bestBuyCarmen < bestBuy)bestBuy= bestBuyCarmen;
print out the table with $/kg andthen print the best buy value.
Company Price Weight Purity Dollars$/kg
Admiral 3.50 10 0.60 0.583
Bosh 5.00 7.5 0.98 0.680
Carmen 4.00 7.5 0.93 0.573
The best buy value is 0.573