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
Explanation / Answer
please rate - thanks if this is supposed to go to a file let me know, I'll make thechangs this is the above program modified as per your request #include #include int main() { // Declare all twelve of the company variables. No arrays inthis example float admiralWeight, admiralPurity, admiralPrice,admiralDollars; float boshWeight, boshPurity, boshPrice, boshDollars; float carmenWeight, carmenPurity, carmenPrice, carmenDollars; // Declare the best value and set it to a really high number so weknow it doesn't start at a good value float bestValue = 999999; // Decide what all of our variables should equal admiralPrice = 3.50; boshPrice = 5.00; carmenPrice = 4.00; admiralWeight = 10; boshWeight = 7.5; carmenWeight = 7.5; admiralPurity = 0.6; boshPurity = 0.98; carmenPurity = 0.93; // Calculate the dollars per kg for each company admiralDollars = admiralPrice / admiralWeight / admiralPurity; boshDollars = boshPrice / boshWeight / boshPurity; carmenDollars = carmenPrice / carmenWeight / carmenPurity; // Check to see what the best value is if(admiralDollarsRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.