Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void initialize(); //self explinetry
- void listAward(); //self explinetry
- void replenishStock(); //self explinetry
- void listSelectedDVD(string); //self explinetry
- struct Stock {
- string Title;
- double Price;
- int Stocklevel;
- bool Award;
- Stock::Stock(string s, double p, int i, bool a){
- Title = s;
- Price = p;
- Stocklevel =i;
- Award =a;
- };
- }myStock[5]; //create struct as a global
- int main() {
- int choice;
- string title;
- initialize();
- cout<<"*****************Main Menu ***************";
- cout<<"1. List all DVD with Awards n";
- cout<<"2. Stock up DVD n";
- cout<<"3. List details of selected title n";
- cout<<"4. Exit. n";
- cout<<"Enter choice. n";
- cin>>choice;
- if (choice == 1) listAward();
- else if (choice==2) replenishStock();
- else if (choice==3){
- cout<<"Enter title n";
- getline(cin,title);
- listSelectedDVD(title);
- }
- else if (choice==4) return 0; //self explinetry
- return 0;
- }
- void initialize(){ //self explinetry
- myStock[0] = Stock("Ilo Ilo",35.55,15,true);
- myStock[1] = Stock("Money Just Enough",10.35,0,false);
- myStock[2] = Stock("My Mother-in-Law",22.50,5,false);
- myStock[3] = Stock("Stars",22.95,1,true);
- myStock[4] = Stock("Moon",40.50,5,false);
- }
- void listAward(){
- for(int i=0;i<5;i++){
- if (myStock[i].Award==true){
- cout<<myStock[i].Title <<" has won an award n";
- }
- }
- }
- void replenishStock() {
- for(int i=0;i<5;i++){
- if (myStock[i].Stocklevel<2){
- if (myStock[i].Award==true){
- myStock[i].Stocklevel+=10;
- }
- else{
- myStock[i].Stocklevel+=5;
- }
- }
- }
- }
- void listSelectedDVD(string name){
- bool flag = false;
- for(int i=0;i<5;i++){
- if (myStock[i].Title ==name){
- cout<<"Title : "<<myStock[i].Title<<endl;
- cout<<"Price : "<<myStock[i].Price<<endl;
- cout<<"Stock : "<<myStock[i].Stocklevel<<endl;
- cout<<"Award : "<<myStock[i].Award<<endl;
- flag = true;
- }
- }
- if (flag==false){ //self explinetry
- cout<< "Title not Found or invalid"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement