In the month of RAMZAN people distribute food packages. Carrefour offers a food package which contains
the following items 10kg flour, 5kg rice, 5ltr oil, 2pack salt and 500gm spices. Price of above items are:
1. Flour per kg 95
2. Rice per kg 210
3. Oil per liter 410
4. Salt per pack 50
5. Spices per 10 grams 5
Write a C++ program in which, take number of required bag from user and calculate the total price of
required packages and display it on console.
#include<iostream>
#include<string>
#include <fstream>
using namespace std;
int main()
{
float totalPrice;
float flourPrice=95*10;
float ricePrice=210*5;
float oilPrice= 410*5;
float saltPrice=50*2;
float spicesPrice=(500/10)*5;
int numberRequiredBag;
cout<<"Enter a number of required bag: ";
cin>>numberRequiredBag;
totalPrice=numberRequiredBag*(flourPrice+ricePrice+oilPrice+saltPrice+spicesPrice);
cout<<"The total price of required packages: "<<totalPrice<<"\n";
cin>>totalPrice;
return 0;
Comments
Leave a comment