Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
thumb_up100%
C++ Programming
main.cc file
#include <iostream> | |
#include <map> | |
#include <vector> | |
#include "bank.h" | |
int main() { | |
// =================== YOUR CODE HERE =================== | |
// 1. Create a Bank object, name it anything you'd like :) | |
// ======================================================= | |
// =================== YOUR CODE HERE =================== | |
// 2. Create 3 new accounts in your bank. | |
// * The 1st account should belong to "Tuffy", with | |
// a balance of $121.00 | |
// * The 2nd account should belong to "Frank", with | |
// a balance of $1234.56 | |
// * The 3nd account should belong to "Oreo", with | |
// a balance of $140.12 | |
// ======================================================= | |
// =================== YOUR CODE HERE =================== | |
// 3. Deactivate Tuffy's account. | |
// ======================================================= | |
// =================== YOUR CODE HERE =================== | |
// 4. Call DisplayBalances to print out all *active* | |
// account balances. | |
// ======================================================= | |
} |
bank.h file
#include <algorithm> | |
#include <cstdlib> | |
#include <iostream> | |
#include <map> | |
#include <memory> | |
#include <string> | |
#include "account.h" | |
class Bank { | |
public: | |
// ======================= YOUR CODE HERE ======================= | |
// Write the Bank class here. Refer to the README for the member | |
// variables, constructors, and member functions needed. | |
// | |
// Note: mark functions that do not modify the member variables | |
// as const, by writing `const` after the parameter list. | |
// Pass objects by const reference when appropriate. | |
// Remember that std::string is an object! | |
// =============================================================== | |
private: | |
// We provided this helper function to you to randomly generate | |
// a new Bank Account ID to be used in CreateAccount. | |
intGenerateAccountId() const { | |
returnstd::rand() % 9000 + 1000; // [1000, 9999] | |
} | |
}; |
bank.cc file
#include "bank.h" | |
// ========================= YOUR CODE HERE ========================= | |
// This implementation file (bank.cc) is where you should implement | |
// the member functions declared in the header (bank.h), only | |
// if you didn't implement them inline within bank.h. | |
// | |
// Remember to specify the name of the class with :: in this format: | |
// <return type> MyClassName::MyFunction() { | |
// ... | |
// } | |
// to tell the compiler that each function belongs to the Bank class. | |
// =================================================================== |
account.h file
#include <string>
class Account {
public:
Account(const std::string& name, double balance)
: account_holder_(name), balance_(balance) {}
const std::string& GetAccountHolder() const {
return account_holder_;
}
double GetBalance() const {
return balance_;
}
private:
std::string account_holder_;
double balance_;
};
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 6 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++main.cc file #include <iostream>#include <map>#include <vector> #include "bank.h" int main() { // =================== YOUR CODE HERE =================== // 1. Create a Bank object, name it anything you'd like :) // ======================================================= // =================== YOUR CODE HERE =================== // 2. Create 3 new accounts in your bank. // * The 1st account should belong to "Tuffy", with // a balance of $121.00 // * The 2nd account should belong to "Frank", with // a balance of $1234.56 // * The 3nd account should belong to "Oreo", with // a balance of $140.12 // ======================================================= // =================== YOUR CODE HERE =================== // 3. Deactivate Tuffy's account. // ======================================================= // =================== YOUR CODE HERE =================== // 4. Call DisplayBalances to print out all *active* // account…arrow_forward// FILE: IntSet.h - header file for IntSet class// CLASS PROVIDED: IntSet (a container class for a set of// int values)//// CONSTANT// static const int MAX_SIZE = ____// IntSet::MAX_SIZE is the highest # of elements an IntSet// can accommodate.//// CONSTRUCTOR// IntSet()// Pre: (none)// Post: The invoking IntSet is initialized to an empty// IntSet (i.e., one containing no relevant elements).//// CONSTANT MEMBER FUNCTIONS (ACCESSORS)// int size() const// Pre: (none)// Post: Number of elements in the invoking IntSet is returned.// bool isEmpty() const// Pre: (none)// Post: True is returned if the invoking IntSet has no relevant// relevant elements, otherwise false is returned.// bool contains(int anInt) const// Pre: (none)// Post: true is returned if the invoking IntSet has anInt as an// element, otherwise false is returned.// bool isSubsetOf(const IntSet& otherIntSet) const//…arrow_forwarduse c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forward
- #include <iostream> #include <iomanip> #include <string> #include <vector> using namespace std; class Movie { private: string title = ""; int year = 0; public: void set_title(string title_param); string get_title() const; // "const" safeguards class variable changes within function string get_title_upper() const; void set_year(int year_param); int get_year() const; }; // NOTICE: Class declaration ends with semicolon! void Movie::set_title(string title_param) { title = title_param; } string Movie::get_title() const { return title; } string Movie::get_title_upper() const { string title_upper; for (char c : title) { title_upper.push_back(toupper(c)); } return title_upper; } void Movie::set_year(int year_param) { year = year_param; } int Movie::get_year() const { return year; } int main() { cout << "The Movie List program\n\n"…arrow_forward#include <iostream>#include <cstdlib>#include <time.h>#include <chrono> using namespace std::chrono;using namespace std; void randomVector(int vector[], int size){ for (int i = 0; i < size; i++) { //ToDo: Add Comment vector[i] = rand() % 100; }} int main(){ unsigned long size = 100000000; srand(time(0)); int *v1, *v2, *v3; //ToDo: Add Comment auto start = high_resolution_clock::now(); //ToDo: Add Comment v1 = (int *) malloc(size * sizeof(int *)); v2 = (int *) malloc(size * sizeof(int *)); v3 = (int *) malloc(size * sizeof(int *)); randomVector(v1, size); randomVector(v2, size); //ToDo: Add Comment for (int i = 0; i < size; i++) { v3[i] = v1[i] + v2[i]; } auto stop = high_resolution_clock::now(); //ToDo: Add Comment auto duration = duration_cast<microseconds>(stop - start); cout << "Time taken by function: " << duration.count()…arrow_forwardGame of Hunt in C++ language Create the 'Game of Hunt'. The computer ‘hides’ the treasure at a random location in a 10x10 matrix. The user guesses the location by entering a row and column values. The game ends when the user locates the treasure or the treasure value is less than or equal to zero. Guesses in the wrong location will provide clues such as a compass direction or number of squares horizontally or vertically to the treasure. Using the random number generator, display one of the following in the board where the player made their guess: U# Treasure is up ‘#’ on the vertical axis (where # represents an integer number). D# Treasure is down ‘#’ on the vertical axis (where # represents an integer number) || Treasure is in this row, not up or down from the guess location. -> Treasure is to the right. <- Treasure is to the left. -- Treasure is in the same column, not left or right. +$ Adds $50 to treasure and no $50 turn loss. -$ Subtracts…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education