Arpit Code(New)
Arpit Code(New)
#include <vector>
#include <memory>
Class Subscription {
Protected:
String name;
Double price;
Public:
Cout << “Subscription: “ << name << “ | Price: $” << price << endl;
};
Int duration;
Public:
Cout << “Monthly Subscription: “ << name << “ | Price: $” << price
<< “ per month | Duration: “ << duration << “ months” << endl;
}
};
Double discount;
Public:
Cout << “Yearly Subscription: “ << name << “ | Price: $” << price
<< “ per year | Discount: “ << discount << “%” << endl;
};
Cout << “Comparing “ << y1.name << “ and “ << y2.name << “…” << endl;
Cout << y1.name << “ is cheaper than “ << y2.name << endl;
Cout << y2.name << “ is cheaper than “ << y1.name << endl;
Else
Cout << “Both subscriptions have the same price.” << endl;
}
Void manageSubscriptions() {
Vector<unique_ptr<Subscription>> subscriptions;
Int choice;
Do {
Switch (choice) {
Case 1: {
String name;
Double price;
Int duration;
Cout << “Invalid input! Please enter positive values.” << endl;
Break;
}
Subscriptions.push_back(make_unique<MonthlySubscription>(name, price,
duration));
Break;
Case 2: {
String name;
Cout << “Invalid input! Please enter positive values.” << endl;
Break;
Subscriptions.push_back(make_unique<YearlySubscription>(name, price,
discount));
Break;
Case 3: {
If (subscriptions.empty()) {
Break;
Sub->display();
}
Break;
Case 4: {
Int I, j;
Break;
comparePrices(*y1, *y2);
else
cout << “Invalid selections! Ensure you are selecting Yearly Subscriptions.” << endl;
break;
Case 5:
Break;
Default:
Int main() {
manageSubscriptions();
return 0;