Question
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the Buy
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the Buy One Get One sale.
#include
//main function int main() { int cartons; float price, total;
//prompt user for input information printf("What is the cost of one container of OJ in dollars? "); scanf(" [ Select ] ["%d", "%c", "%f", "%lf"] ", &price);
printf("How many containers are you buying? "); scanf(" [ Select ] ["%d", "%c", "%f", "%lf"] ", &cartons);
if ( [ Select ] ["cartons / 2", "cartons % 1", "cartons % 2", "cartons % price", "cartons / price", "cartons / total"] [ Select ] ["=", "==", "!=", "<=", ">=", "<"] 0) total = [ Select ] ["price * cartons", "cartons * price / 2 + price", "(cartons / 2) * price", "cartons / (2.0 * price)", "(cartons / 2.0) * price + price", "((cartons / 2) * price) + price"] ; else total = ((cartons / 2) * price) + price;
printf("The total cost is $%.2f. ", total);
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started