Answer:
In C++:
#include <iostream>
using namespace std;
class VendingMachine {
public:
int initial = 20;};
int main() {
VendingMachine myMachine;
int purchase, restock;
cout<<"Purchase: "; cin>>purchase;
cout<<"Restock: "; cin>>restock;
myMachine.initial-=(purchase-restock);
cout << "Inventory: "<<myMachine.initial<<" bottles";
return 0;}
Step-by-step explanation:
This question is incomplete, as the original source file is not given; so, I write another from scratch.
This creates the VendingMachine class
class VendingMachine {
This represents the access specifier
public:
This initializes the inventory to 20
int initial = 20;};
The main begins here
int main() {
This creates the object of the VendingMachine class
VendingMachine myMachine;
This declares the purchase and the restock
int purchase, restock;
This gets input for purchase
cout<<"Purchase: "; cin>>purchase;
This gets input for restock
cout<<"Restock: "; cin>>restock;
This calculates the new inventory
myMachine.initial-=(purchase-restock);
This prints the new inventory
cout << "Inventory: "<<myMachine.initial<<" bottles";
return 0;}