T

@thomascutler

8.4 BUILD | Unit 8 Project: Words in a Document

C++
3 months ago
#include <iostream> #include <vector> #include <string> using namespace std; int main() { vector<string*> uniqueWords; vector<string*> document;

8.3 CONNECT | Students & Grades

C++
3 months ago
#include <iostream> #include <string> #include <vector> #include <map> using namespace std; struct Student { string first_name; string last_name;

8.2c Employees & Managers

C++
3 months ago
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; class Employee { private: string name;

8.2b Custom Address Printing

C++
3 months ago
#include <iostream> using namespace std; struct StreetAddress { int house_number; string street_name; }; void print_address(StreetAddress address, bool number_first)

8.2a Sorting Values of Pointers

C++
3 months ago
#include <iostream> using namespace std; void swap(double* a, double* b) { double temp = *a; *a = *b; *b = temp; }

8.1c Printing Addresses

C++
3 months ago
#include <iostream> using namespace std; int main() { int num1 = 100; int num2 = num1; int &num3 = num1; cout << "Address of num1 is " << &num1 << "\n";

8.1b Happy Birthday Function

C++
3 months ago
#include <iostream> using namespace std; void happyBirthday(int& age){ age += 1; } int main() { int my_age = 15;

8.1a Twin Birthdays

C++
3 months ago
#include <iostream> using namespace std; int main() { int person1_age = 15; int& person2_age = person1_age; cout << "Person 1 and Person 2 are twins." << endl;

7.4 BUILD | Unit 7 Project: Making a Letter

C++
3 months ago
#include <string> #include <vector> #include <iostream> class Letter { public: Letter(std::string from, std::string to); // Constructor void add_line(std::string line); // Add a line of text to the body of the letter std::string get_text(); // Get the entire text of the letter

7.3 CONNECT | Moth to a Light

C++
4 months ago
#include <iostream> using namespace std; class Moth { public: Moth(double initial_position); // Constructor void move_to_light(double light_position); // Move moth towards a light source double get_position(); // Get current position of the moth private: double position; // Position of the moth along the x-axis

7.2c Shuttle Van

C++
4 months ago
#include <iostream> using namespace std; /** This class models a shuttle van. */ class Van { public: Van(int max_passengers);

7.2b Keypad Lock

C++
4 months ago
#include <iostream> using namespace std; class Lock { public: void push(int button); // Simulates a digit button push bool open(); // Simulates a push of the open button private: int combination = 1729; // Predefined combination int input = 0; // Digits entered by the user

7.2a Traffic Light With a Counter

C++
4 months ago
#include <iostream> #include <string> using namespace std; /** A simulated traffic light. */ class TrafficLight { public:

7.1c Shuffling Cards

C++
4 months ago
#include <iostream> #include <cstdlib> #include <vector> #include <ctime> // Include <ctime> for srand() and rand() functions using namespace std; // Define a Card class class Card { public:

7.1b Digital Clock

C++
4 months ago
#include <iostream> using namespace std; class Clock { public: void reset(); // Sets the clock to 00:00 void pulse(); // Advances the clock to the next minute int get_hours() const; // Gets the hours of the clock int get_minutes() const; // Gets the minutes of the clock private:

7.1a Cash Register

C++
4 months ago
#include <iostream> #include <vector> #include <numeric> using namespace std; class CashRegister { public: void clear(); void add_item(double price);

6.6b CONNECT | String Scramble

C++
4 months ago
#include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int random(int min, int max) { return min + rand() % (max - min + 1); }

6.5d Biggest Number

C++
4 months ago
#include <iostream> using namespace std; template<typename T> T get_biggest(T num1, T num2, T num3) { T biggest = num1; if (num2 > biggest) { biggest = num2; } if (num3 > biggest) {

6.5c Adding Numbers

C++
4 months ago
#include <iostream> using namespace std; int add(int num1, int num2) { int sum = num1 + num2; return sum; } int add(int num1, int num2, int num3) { int sum = num1 + num2 + num3;

6.5b Ice Cream Order

C++
4 months ago
#include <iostream> using namespace std; string order_ice_cream (string flavor, int scoops = 2, string cone_or_dish = "cone") { string order = "You ordered " + to_string(scoops) + " scoops of " + flavor + " ice cream in a " + cone_or_dish + "."; return order; } int main() {