Objectives: • Perform C++ user-define object manipulations • Define class using OO approach • Understand how to create and manipulate list of objects using vector class • Handle input errors and invalid values • Design and create a well-structure program using C++ basic programming constructs and classes. Description: Simply enhance programming project #2 (Manage Expenses) with the followings: 1. Define a new class named “Expense” that manages an expense amount and its description 2. Use Vector class instead of array to manage a list of Expense objects 3. Add support for a new “search” command for expenses that contain the search string Requirements: 1. The program should continue to work as described in project #2 even though internally it uses new vector object that manages a list of Expense objects... 2. The program now accepts a new added command: search search-string where it displays a list of expenses that has description that contains the search string Required error handling: The program MUST still have the same error handling as required in project #2 Extra credit: • Add a new “delete” command that accepts the amount of expense and it will go through the list of all the expenses that has amount.
Thanks for the question.
Here is the completed code for this problem. Let me know if you
have any doubts or if you need anything to change.
Thank You !!
=============================================================================================
// Expense.header file
#ifndef EXPENSE_H
#define EXPENSE_H
#include<string>
using namespace std;
class Expense
{
public:
Expense();
Expense(string,double);
string getDescription()const;
double getAmount() const;
void setDescription(string);
void setAmount(double);
private:
string description;
double amount;
};
#endif
=============================================================================================
// Expense.cpp file
#include "Expense.h"
#include<string>
using namespace std;
Expense::Expense():description{""},amount{0}{
}
Expense::Expense(string description,double
amount):description{description},amount{amount}{
}
string Expense::getDescription()const {
return this->description;
}
double Expense::getAmount() const{
return this->amount;
}
void Expense::setDescription(string desc){
this->description=desc;
}
void Expense::setAmount(double amount){
this->amount=amount;
}
=============================================================================================
// main.cpp file
#include <iostream>
#include<string>
#include<vector>
#include "Expense.h"
using namespace std;
void searchItem(const vector<Expense> &items,
string search){
for(int index=0; index<items.size();index++){
if(items.at(index).getDescription().compare(search)==0){
cout<<"Item Description:
"<<items.at(index).getDescription()<<", Expense Amount:
$"<<items.at(index).getAmount()<<endl;
}
}
}
void deleteItem(vector<Expense> &items, double
amount){
vector<Expense>::iterator it;
for(it=items.begin();it!=items.end();it++){
if(it->getAmount()==amount){
cout<<"Item Description:
"<<it->getDescription()<<", Expense Amount:
$"<<it->getAmount()<<" deleted."<<endl;
items.erase(it);
it--;
}
}
}
int main(void) {
vector<Expense> expenses;
expenses.push_back(Expense("Mobile",400));
expenses.push_back(Expense("Shirt",450));
expenses.push_back(Expense("Trousers",600));
expenses.push_back(Expense("Laptop",1000));
expenses.push_back(Expense("Watch",400));
int choice=0;
string search;
double amount;
while(choice!=3){
cout<<"[1] Search an
item"<<endl;
cout<<"[2] Delete an
item"<<endl;
cout<<"[3]
Exit"<<endl;
cout<<"Enter choice:
";cin>>choice;cin.get();
switch(choice){
case 1:
cout<<"Enter description of the item you
want to search: ";
getline(cin,search);
searchItem(expenses,search);
break;
case 2:
cout<<"Enter the amount you want to
delete: ";cin>>amount;
deleteItem(expenses,amount);
break;
case 3:
cout<<"Thanks for using. Good Bye
!";
}
}
}
=============================================================================================

Objectives: • Perform C++ user-define object manipulations • Define class using OO approach • Understand how...
Define a C++ class managing objects using a
Linked List.
(10 points) Define a C++ class named "BirthdayList" that manages a list of Birthday objects as a linked list maintaining the order of entry (first birthday should be displayed first). Write a main function to show that you can add a list of birthdays and print out that list in the order that you have entered. (5 points) Add a "search" method into the "BirthdayList" class that accepts a Birthday...
All commands must be in the command line. The expense data file is separate. Programming Project #2: Manage Spending Using Commands Objectives: • Understand how to create and manipulate list of objects using array or vector class • Handle input errors and invalid values • Design and create a well-structure program using C++ basic programming constructs and classes. Description: Each “expense” contains 2 values: the spending amount (double) and its description (string) Here is an example of the “expense” data...
Project Lists and Object-oriented Programming Note: using c++ This project is an individual assignment that focuses on object-oriented programming and lists. The list will be a doubly-linked list and it will be implemented using nodes and pointers. The data contained in the list will be objects from a class. Project data: You will choose one of the following classes to define: Boat, Earthquake, Game, Sport, State, Website, House, Phone, Activist, Plant, Fish, Parrot, and Course. Your class code will include...
I need help writing this code in C++ and I’m using xcode for
mac
the
objective is in the first picture and the rest is a sample output
of the code thaf needs to be similar
bjectives: . Perform C++ string object manipulation Understand how to manipulate data using arrays of structs Handle input errors and invalid values Design and create a wel-structure program using C++ basic programming constru Description: Write a menu-driven program that provides the following options 1....
Please I need help a sample code is provided below of the
output
Description This project is an enhancement of your previous project using OOP concepts. You'lI define class and instantiate objects instead of using struct to implement your design Write a menu-driven program that provides the following options 1. Show All 2. Spend 3. Search expenses containing this string 4. Search expenses with greater than or equal to this amount 5. Exit It allows the user to select a...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
C++ Define a class called Text whose objects store lists of words. The class Text will be just like the class StringVar except that the class Text will use a dynamic array with base type StringVar rather than base type char and will mark the end of the array with a StringVar object consisting of a single blank, rather than using '\0' as the end marker. Intuitively, an object of the class Text represents some text consisting of words separated...
2-1. Define and implement a class named cart. A cart object represents a horse drawn cart that can seat up to four meerkats, after that meerkats have to walk. The meerkats must be represented by meerkat objects. The cart class has the following constructors and behaviours: cort)i bool addleerkat(meerkat cat); vold enptyCort() void printMeerkats0 // create an erpty cart object // dd, ?"eerkat to the cart, returns false if full // renove all reerkats from the core print the nane,...
Please use C++,thank you!
Write an AddressBook class that manages a collection of Person objects. Use the Person class developed in question 2. An AddressBook will allow a person to add, delete, or search for a Perso n object in the address book The add method should add a person object to the address book. The delete method should remove the specified person object from the address book 0 .The search method that searches the address book for a specified...
C++, Visual Studio
(Optional-Extra Credit) Write an AddressBook class that manages a collection of Person objects. Use the Person class developed in question Lab 4 Question 2. An AddressBook will allow a person to add, delete, or search for a Person object in the address book 1. The add method should add a person object to the address book .The delete method should remove the specified person object from the address book .The search method that searches the address book...