Creat a program with the compilation of your activities in prelim
structure Address with data members:
1. char* address
2. char* city
3. char* state
4. int zip_code
structure CustomerAccount with data members:
1. char* name
2. Address address
3. long long phoneNum
4. float balance
5. char* accountNum
arguments to all the global functions :
1. CustomerAccount *customers[100]
2. int accountsOpen
functions in global scope:
1. void OpenCustomerAccount (CustomerAccount* customers[], int& accountsOpen,
char* NameVal, char*addVal, char*cityVal, char*stateVal, int zipcodeVal, long long
phoneVal, float balanceVal)
2. int SearchCustomer (CustomerAccount* customers[], int accountsOpen, char*
accountNum)
3. bool UpdateCustomerAccount (CustomerAccount* customers[], int accountsOpen, char
*accountNumVal, Address addressVal)
4. bool UpdateCustomerAccount (CustomerAccount* customers[], int accountsOpen,
char *accountNumVal, long long phoneVal)
5. bool UpdateCustomerAccount (CustomerAccount* customers[], int accountsOpen, char
*accountNumVal, float balanceVal)
Implement your own string class using only primitive data types. Your string class should contain some of the same functionality as the string class in C++.
Your class should have the following member variables:
1. char *data
2. int length
Your object should have the following constructors and destructor:
1. String(): default constructor
2. String(int size)
3. String(char* str)
Note: You can assume that any character array that is sent as str will be terminated
by a null character (‘\0’)
4. String(const String &str)
5. ~String()
Your class should have the following functions:
1. int strLength()
2. void clear()
3. bool empty()
4. int charAt(char c)
5. char* getdata()
6. bool equals(char*str)
7. bool equalsIgnoreCase(char* str)
8. char* substring(char* substr, int startIndex)
9. char* substring(char* substr, int startIndex, int endIndex)
10. void print()
A restaurant serves five different kinds of sandwiches.
Implement a class Sandwich that includes the following private data members:
1. char *name – a sting to store the sandwich name
2. char *filling – sandwich filling
3. char *size – size of the sandwich (can only be small, medium or large)
4. bool is_ready – sandwich, is it ready or not
5. double price - price of the sandwich.
The class shall provide the following public methods:
1. Sandwich() – a default constructor
2. Sandwich(char *fillingVal, double priceVal) – a parametrized constructor
3. Sandwich(char *fillingVal, double priceVal, char* nameVal, char* sizeVal, bool
ready_status)
4. Sandwich(const Sandwich &sandwich)
5. void setFilling(char *fillingVal)
6. void setPrice(double priceVal)
7. void setName(char *nameVal)
8. void setSize(char *sizeVal)
9. char* getFilling()
10. double getPrice()
11. char* getName()
12. char* getSize()
13. void makeSandwich()
14. bool check_status()
Implement a class Sequence to store a sequence of non-negative integer values, and the length
of the sequence. The class has the following private data members:
1. int length – the length of the sequence
2. int *pseq – a pointer to a dynamic integer array holding sequence of integers
The class shall provide the following public methods:
1. Sequence() – a default constructor that initializes length to 10 and store the sequence of
all zeros in an array.
2. Sequence(int lengthVal, int n1=0,int n2=0,int n3=0, int n4=0, int n5=0, int n6=0, int n7=0,
int n8=0, int n9=0, int n10=0) – another parameterized constructor should initialize the
length and array to sequence values passed in the arguments.
3. Sequence(Sequence &s) – a copy constructor that creates a copy of a Sequence object.
4. int getLength() – a getter for length
5. int* getSeq() – a getter for the sequence of numbers
6. void Sort(int n) – a function that sorts the first n elements in the sequence array. You
cannot use Bubble Sort Algorithm
Implement a class Matrix to create matrices of 2x2, 3x3 and 4x4 with the following private data members:
1. int **matrix – a double pointer of type integer to create a 2D array (matrix)
2. int row – an integer to store the rows in the matrix
3. int col – an integer to store the columns in the matrix
The class shall have the following public member functions:
1. Matrix (int n1, int n2, int n3, int n4, int row = 2, int col = 2) – a parametrized
constructor for a 2x2 matrix
2. Matrix (int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int row = 3,
int col = 3) – a parametrized constructor for a 3x3 matrix
3. Matrix (int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, int n10, int
n11, int n12, int n13, int n14, int n15, int n16, int row = 4, int col = 4) – a
parametrized constructor for a 4x4 matrix
4. Matrix(const Matrix &m) – a copy constructor
5. ~Matrix() – a destructor
6. int getRow() – a getter for rows
7. int getCol() – a getter for columns
Implement a structure, Car. The structure has the following data member:
1. int petrolLevel – that indicates the liters of petrol in the car’s petrol tank. PetrolLevel for
this car can only be in the range 0 – 45 liters.
The structure has the following member functions:
1. void setPetrolLevel(int petrolLevelVal) – a setter for petrol level, cannot set value greater
than 45.
2. int getPetrolLevel() – a getter for petrolLevel
3. Car() – a default constructor
4. Car(int petrolLevelVal) – a parametrized constructor
5. bool MoveCar(int distanceKM) – a function that takes an integer as an argument and
moves the car to the argument value which is in Km. Provided the petrol tank has enough
fuel. Successful movement of the car returns true otherwise returns false. Moving for
each km causes the petrolLevel to go low by one.
6. void Refill() – a function that refills the car tank to the maximum value of petrolLevel
7. bool isEmpty() – a function that tells whether the Petrol tank is Empty or not
Write a recursive function that returns number of occurrences of a certain letter in a given string.
Let the function prototype be int countLetter(char letter, string str). For example, if
letter = "l" and str = "lollipop", the function should return 3.
You've learned in the past lessons on how to use square root functions, right? Then let's take your knowledge to the test. Print out the square root of a given integer with only two decimal places.
Ready, solve, and go!
Input
A line containing an integer.
4
Output
A line containing a decimal with two decimal places.
2.00
by CodeChum Admin
Make me a program that accepts two random strings. Then, count the number of vowels that are in each of the strings and put it on separate variables.
Finally, for the survival of the vowels, subtract the total count of vowels of the first string to the vowels of the second string then print out its difference.
Easy, right? Then go and code as if your life depends on it!
Input
Two lines containing a string on each.
C++·is·fuN
CodeChum·is·AWEsomeOutput
A line containing an integer.
6