Write a C++ program which takes the price of bakery items ranging from 0-999

Write a C++ program for purchased bakery items and to find their average

Write a C++ program which takes the price of bakery items ranging from 0-999

Object:

Write a C++ program which takes the price of bakery items ranging from 0-999

  • if you enter PKR 1-200 it should show cakes
  • if PKR 200 – 400 SHOW BISCUITS
  • if PKR 400- 700 show miscellaneous
  • if PKR 700 – 999 show ice cream your program to should run 3 times using While loop in the end also take the average of all items price. C++ Projects.

Code:

#include<iostream>
#include<conio.h>

using namespace std;
void main()
{
int price, bisc, cake, icr, misc;
float sum=0, avg, purch=1;
while(purch<=3)
{
cout<<“\nPlease Enter the price Bakery items: “;
cin>>price;
//condition
if(price > 0 && price < 999)
{
sum=price+sum;
avg=sum/purch;
if(price >= 1 && price < 200)
{
cout<<“Your Order for Cake.”<<endl;
cin>>cake;
cout<<“\nYou Ordered for “<<cake<<” Cake.”<<endl;
}
else if(price >=200 && price < 400)
{
cout<<“Your Order for Biscuits.”<<endl;
cin>>bisc;
cout<<“\nYou Ordered for “<<bisc<<” Biscuits.”<<endl;
}
else if(price >=400 && price < 700)
{
cout<<“Your Order for Miscellaneous.”<<endl;
cin>>misc;
cout<<“\nYou Ordered for “<<misc<<” Miscellaneous.”<<endl;
}
else if(price >=700 && price < 999)
{
cout<<“Your Order for Ice Cream.”<<endl;
cin>>icr;
cout<<“\nYou Ordered for “<<icr<<” Ice Cream.”<<endl;
}
}
purch++;
}
cout<<“\nThe Average of all items Price is: “<<avg<<endl;
getch();
}

#include<iostream>
#include<conio.h>

using namespace std;
void main()
{
	int price, bisc, cake, icr, misc;
	float sum=0, avg, purch=1;
	while(purch<=3)
	{
		cout<<"\nPlease Enter the price Bakery items: ";
		cin>>price;
		//condition
		if(price > 0 && price < 999)
		{
			sum=price+sum;
			avg=sum/purch;
			if(price >= 1 && price < 200)
			{
				cout<<"Your Order for Cake."<<endl;
				cin>>cake;
				cout<<"\nYou Ordered for "<<cake<<" Cake."<<endl;
			}
			else if(price >=200 && price < 400)
			{
				cout<<"Your Order for Biscuits."<<endl;
				cin>>bisc;
				cout<<"\nYou Ordered for "<<bisc<<" Biscuits."<<endl;
			}
			else if(price >=400 && price < 700)
			{
				cout<<"Your Order for Miscellaneous."<<endl;
				cin>>misc;
				cout<<"\nYou Ordered for "<<misc<<" Miscellaneous."<<endl;
			}
			else if(price >=700 && price < 999)
			{
				cout<<"Your Order for Ice Cream."<<endl;
				cin>>icr;
				cout<<"\nYou Ordered for "<<icr<<" Ice Cream."<<endl;
			}
		}
		purch++;
	}
	cout<<"\nThe Average of all items Price is: "<<avg<<endl;
	getch();
}

Output:

Write a C++ program which takes the price of bakery items ranging from 0-999

Another Program: Write a C++ Program to print the bill.

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

4 Responses

  1. Jung Pihl says:

    Greetings! This is my 1st comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading your blog posts. Can you recommend any other blogs/websites/forums that cover the same subjects? Thanks!

  2. Frank says:

    When someone writes an article he/she retains the image of a user in his/her
    brain that how a user can be aware of it. Thus that’s why this article is perfect.
    Thanks!

  1. June 4, 2020

    […] Another Program: Write a C++ program which takes the price of bakery items ranging from 0-999 […]

  2. December 24, 2020

    […] Write a C++ program which takes the price of bakery items ranging from 0-999 […]

Leave a Reply

Your email address will not be published. Required fields are marked *