C++ programming
Phone Book
Create a class that can be used for a Phone Book. The class should have attributes for the name and phone number. The constructor should accept a name and a phone number. You should have methods that allow the name to be retrieved, the phone number to be retrieved, and one to allow the phone number to be changed. Create a toString() method to allow the name and number to be printed.
Write a program that creates a vector that can contain phone numbers. The program should prompt the user for an indeterminate number of phone numbers, create a phone number object, and add the object to the vector. After each phone number that is entered the program should display the phone number object that was just created and the total number of phone numbers in the list/vector. When the user has finished entering phone numbers into their phone book, the program should display the contents of the phone list (complete list of names/numbers).
This program should be tested at least three times with differing quantities of phone numbers.
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class PhoneBook {
private:
string name;
string phoneNumber;
public:
PhoneBook(const string &name, const string &phoneNumber) : name(name), phoneNumber(phoneNumber) {}
string getName() const {
return name;
}
string getPhoneNumber() const {
return phoneNumber;
}
void change(string name, string phoneNumber) {
this->name = name;
this->phoneNumber = phoneNumber;
}
string toString() {
string result = "Name: " + name + ", Phone number: " + phoneNumber;
return result;
}
};
int main() {
vector<PhoneBook> phoneBook;
string name, number;
int n;
cout << "How many numbers do you want to enter: ";
cin >> n;
getline(cin, name);
for(int i = 0; i < n; ++i) {
cout << "Enter name: ";
getline(cin, name);
cout << "Enter phone number: ";
getline(cin, number);
cout << endl;
PhoneBook p(name, number);
phoneBook.push_back(p);
}
// display phone number
for(int i = 0; i < phoneBook.size(); ++i) {
cout << phoneBook[i].toString() << endl;
}
return 0;
}


C++ programming Phone Book Create a class that can be used for a Phone Book. The...
Phone Book ArrayList Write a class named PhoneBookEntry that has fields for a person’s name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program that creates at least five PhoneBookEntry objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList Copyright | Addison-Wesley | Starting Out with Java | kehindewilliams771@gmail.com | Printed from Chegg iOS App
Write a class named PhoneBookEntry that has fields for a person's name and phone number.The class should have a constructor and appropriate accessor and mutator methods. Thenwrite a program that creates at least five PhoneBookEntry objects and stores them in anArrayLitt. Use a loop to display the contents of each object in the ArrayList.
JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...
Create the following program in java please Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a...
C++ Program 1. Create a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Your application declares an array of 12 BaseballGame objects. Prompt the user for data for each object, and display all the values. Then pass each object to a method that displays the name of the winning team or “Tie” if the score is a tie. (main.cpp,...
In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...
Using arrays create a personal phone directory that contains room for first names and phone numbers for 20 people. Using the "names.txt" retrieve the first name and phone number for each person and store in arrays (parallel). Prompt the user for a name, search for the name, and if name is found in the array, display the corresponding phone number. If the name is not found, prompt the user to enter a phone number, and add the new name and...
DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...
In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...
Create a class called AddressBook. It should be able to store a maximum of 50 names and 50 phone numbers (make an array of structures in the object or two arrays). It should contain a method called addName that will take a name and phone number and add it to the address book. There should be a method called findName that will take a string for the name and return the phone number if found in the list otherwise return...