A beverage manufacturer produces a popular drink in 500 ml cans (0.5 litres). The drink is sold in cases containing 24 cans. To produce 1000 litres of the drink, 59 litres of a special ingredient is required. The remainder consists of water to which 200 kilograms of sugar is added (assume that sugar does not affect volume). Write a program which accepts as input the number of cases of the drink that are required and calculates and displays the following: The amount of litres of the special ingredient required The amount of kilograms of sugar required The amount of water required Must be written in C++, no arrays to be used and only use iostream library
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
A beverage manufacturer produces a popular drink in 500 ml cans (0.5 litres). The drink is sold in cases containing 24 cans. To produce 1000 litres of the drink, 59 litres of a special ingredient is required. The remainder consists of water to which 200 kilograms of sugar is added (assume that sugar does not affect volume).
Write a program which accepts as input the number of cases of the drink that are required and calculates and displays the following:
- The amount of litres of the special ingredient required
- The amount of kilograms of sugar required
- The amount of water required
Must be written in C++, no arrays to be used and only use iostream library
Program:
//included header file
#include<iostream>
//included namespace
using namespace std;
//main funtion
int main()
{
//constant variable declarations
const double can=0.5;
//computed litres of drink in 1 cases
double cases=24*can;
//declare drink
double drink=1000;
//declare ingrediant in 1000 litre
int ingrediant=59;
//computed water content
int water=1000-59;
//declare sugar in 1000 litre
int sugar=200;
//computed ingrediant of 1 cases
double ingrediant1cases=(ingrediant/drink)*cases;
//computed water of 1 cases
double water1cases=(water/drink)*cases;
//computed sugar of 1 cases
double sugar1cases=(sugar/drink)*cases;
//declare variable requiredCases for input
int requiredCases;
//input number of cases from the user
cout<<"Enter the number of cases of the drink that are required: ";
cin>>requiredCases;
//produce output
cout<<"The amount of litres of the special ingredient required: "<<requiredCases*ingrediant1cases<<endl;
cout<<"The amount of kilograms of sugar required: "<<requiredCases*sugar1cases<<endl;
cout<<"The amount of water required: "<<requiredCases*water1cases<<endl;
return 0;
}
Step by step
Solved in 2 steps with 1 images