Write a program to prepare a shopping list – C++ OOP’s In Hindi

C++

Write a program to prepare a shopping listC++ OOP’s Program In Hindi – Aaj Ham C++ OOPs Me Ek Shopping List Program Ko Create Karne Wale Hai.

Also Read – Become A Web Developer In Hindi

Write a program to prepare a shopping list

Is Program Me Ham Ek Class shoppingList Create Karenge Or Uske Under Ham Sabhi Method Yani Function Ko Likhne Wale Hai |

Isme Ham Input Me User Se Items Number Lenge And Fir Un Items Ko Name + Rate + Quantity Ke Sath Output Me Show Karenge |

Example:

#include<iostream>
#include<iomanip>
using namespace std;
class shoppingList
{
  private:
  string itemname;
  int qty;
  float rate;
  public:
  void readitems()
  {
    cout<<endl<<"Enter the item name:";
    cin>>itemname;
    cout<<endl<<"Enter the rate:";
    cin>>rate;
    cout<<endl<<"Enter the quantity:";
    cin>>qty;
  }
  void printitems()
  {
    cout<<setw(15)<<itemname;
    cout<<setw(10)<<qty;
 	cout<<setw(5)<<rate;
 	cout<<setw(8)<<rate*qty<<endl;
	}
};
int main()
{
int n;
cout<<endl<<"Enter the number of items:";
cin>>n;
shoppingList items[n];
for(int i=0;i<n;i++)
{
	items[i].readitems();
}
cout<<setw(30)<<"Shopping List"<<endl;
cout<<setw(15)<<"Item Name"<<setw(10)<<"Quantity"<<setw(5)<<
"Rate"<<setw(8)<<"Amount"<<endl;
for(int i=0;i<n;i++)
{
items[i].printitems();
}
return 0;
}

Output:

Enter the number of items:3
Enter the item name: Pen
Enter the rate:50
Enter the quantity:5
Enter the item name: Pencil
Enter the rate:5
Enter the quantity:10
Enter the item name: Book
Enter the rate:250
Enter the quantity:2
Shopping List
Item Name Quantity Rate Amount
Pen          5      50    250
Pencil       10     5      50
Book         2     250    500

Aap Upper Output Ko Dekh Kar Program Ko Understand Kar Sakte Hai, isme Hame Number Of Items And Fir Unke Value Ko Input Karaya Hai, Uske Bad Hame Unhe Print Kar Diya Hai WIth Amount Ke Sath |

Leave a Reply

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