Cs301 Assignment 1 Solution Vu360
Cs301 Assignment 1 Solution Vu360
#include <iostream>
#include <string>
class ShoppingList {
private:
string items[100];
int itemCount;
public:
ShoppingList() {
itemCount = 0;
items[itemCount] = item;
itemCount++;
} else {
cout << "Shopping list is full. Cannot add more items." << endl;
if (items[i] == item) {
found = true;
itemCount--;
break;
if (!found) {
cout << "Item not found in the shopping list." << endl;
void viewList() {
if (itemCount == 0) {
} else {
void clearList() {
itemCount = 0;
}
};
int main() {
ShoppingList shoppingList;
int choice;
string item;
do {
cout << "1. Add item to the shopping list." << endl;
cout << "2. Remove item from the shopping list." << endl;
cout << "3. View current items in the shopping list." << endl;
switch (choice) {
case 1:
cin.ignore();
getline(cin, item);
shoppingList.addItem(item);
break;
case 2:
cin.ignore();
getline(cin, item);
shoppingList.removeItem(item);
break;
case 3:
shoppingList.viewList();
break;
case 4:
shoppingList.clearList();
break;
case 5:
break;
default:
cout << "Invalid choice. Please choose a valid option." << endl;
return 0;