How this code can be done without #define STOCK 5 #include #include #define STOCKS 5 using namespace std; class receipt { private: string name; double price [STOCKS]; public: receipt( ){ for(int i=0;iname = name; int size=sizeof(s)/sizeof(int); for(int i=0;iprice[i]=s[i]; } void setStocks(int i, double pr) { price[i]=pr; } double getStocks(int i) { return price[i]; } void show (){ cout<<"Magazin: "<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How this code can be done without #define STOCK 5

#include <iostream>
#include<iomanip>
#define STOCKS 5
using namespace std;

class receipt {

private:
string name;

double price [STOCKS];

public:
receipt( ){

for(int i=0;i<STOCKS;i++)
price[i]=0;
}

receipt(string name, double s[] ){
this->name = name;
int size=sizeof(s)/sizeof(int);

for(int i=0;i<STOCKS;i++)
this->price[i]=s[i];
}

void setStocks(int i, double pr) {
price[i]=pr;
}

double getStocks(int i) {
return price[i];
}

void show (){
cout<<"Magazin: "<<name<<endl;
for(int i=0; i<STOCKS;i++)
cout<<"Product #"<<i+1<<" "<<fixed<<setprecision(2)<<price[i]<<": lev"<<endl;
cout<<endl;
}

double total() {
double total=0;
for(int i=0; i<STOCKS;i++)
total+=price[i];
return total;
}

void remove(int i){
for(int t=i;t<STOCKS;t++)
price[t]=price[t+1];
}


void discount(int i,double per){
price[i]+=-price[i]*per*0.01;
}

};

int main (){

double pr[]={10.20, 13.40, 15.10, 16.20, 40.50 };
receipt r1("LIDL",pr);
cout<<"Kasova belejka: "<<endl;
r1.show();
cout<<"Stoinostta na 3 indeks e : ";
cout<<r1.getStocks(3)<<endl<<endl;

r1.setStocks(2,30.0);
cout<<"Sled promianata Product #3 = 30.0 "<<endl;
r1.show();

r1.discount(4, 15);
cout<<"Sled namalenieto 15% na Product #5"<<endl;
r1.show();
cout<<"Obshta cena = "<<r1.total();

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education