C++ in N Questions
Hello ... get your hands dirty
install an IDE, create a project, run a program.
h02 Can you ask user a number and then print out "hello 1", "hello 2", ..., "hello n"?
h03 Can you stop the program on each loop and examine the number n?
Statistics ...
variable, data type, loop, math operators
file IO, string
s11 Can you ask user for n numbers and calculate the average?
s12 Can you ask user for n numbers and calculate average, max, min, and count how many of them are above average?
s13 Can you read in a file of numbers, count how many numbers, and calculate average, max, min? file IO
s14 What if your file has customer name and balance on each line, can you repeat the statistics exercise? string
Reports ...
array, sort
s51 Can you print these numbers from small to large?
s52 Can you print the "median" of these numbers? (oh, this is not easy, later, later)
Complex ...
object, class, operator overloading
c21 Can you design a complex data type with real and img part?
c21.1 Will it support cout << complex1 and cin >> complex1?
c21.2 How about math operations on complex numbers such as c1 = c2+c3; c2 = c2*3?
c21.3 Can it handle constructors of complexType c1(11,22), c2(-33)?
c23 Want more exercise? Try time object which has hour, min and sec.
c25 How about import to the database from different file format?
Time ...
inheritance, composition
t31 Can you design a time data type (with hour, min, sec) and do cout << time1+time2 ?
t32 What if you want to add a timezone to the time class? Can you do it in two forms, one with composition and one with inheritance?
t33 What if you want to reuse the same time type for stop watch by adding millisecond?
t34 How do you leverage the constructor, operators, and functions of parent's class for the derived class?
Customers ...
put together
You have a customer file, each line has a customer number, customer name and the balance. The customer file needs to be updated to reflect any changes.
h51 Can you create a customer class which handles customer's activities (like deposit, withdraw, check balance)?
h52 Can you tally customer statistics (e.g. how many customers, min/max/avg balance)?
h53 Can you find a specific customer (by overloading == operator) and print his balance?
h54 Can you change a customer's balance by adding deposit and withdraw function?
h61 Can you add another customer to the customer file?
h62 Can you delete a customer and recalculate the statistics?
h71 Can you print the customers from small balance to large balance?
h71.1 array of customers with insertion sort, with quick sort?
h71.2 link list of customers with merge sort?
h72 Can you print the customers alphabetically?
hx1 Can you print the customer with median balance?
Q&A