This chapter does not have automatically graded exercises. Design, by its nature, is open-ended. It does however have some exercises that ask you to design functions. Here are some guidelines for how to answer those exercises:
We want to write a program that takes a variable definition in snake_case and converts them to camelCase. So, if we started with the input int my_nice_variable;, we would want to output int myNiceVariable;. The declaration could also have an initial value, like double another_variable_name = 3.14;. If it does, there will always be a space between the variable name and the assignment operator.
Note that we have not described how any of the functions do their job. We have simply identified useful tasks and written down what inputs and outputs they should have. Not all of these functions might be needed. (For example, we could probably just use toupper from <cctype> instead of writing Function 3). And we might need to break up some of the functions more.
We will start with 6 doubles, x1, y1, x2, y2, x3, and y3, that represent the coordinates of the three vertices of a triangle. We want to compute and print the area of the triangle.
We have a string containing two cards of a hand in blackjack, like "KH 7D" (the king of hearts and the seven of diamonds) or "AS 9C" (the ace of spades and the nine of clubs). We want to compute the total value of the hand. The king, queen, and jack are worth 10 points each. The ace is worth either 1 point or 11 points, whichever is more favorable to the hand without going over 21. All other cards are worth their numeric value.
Given two blood types like AB+ and O-, we want to determine if the first blood type can donate to the second blood type and if the second can donate to the first.
Blood that has type A antibodies (A or AB) can only be given to people with an A or AB blood type. Blood that has type B antibodies (B or AB) can only be given to people with a B or AB blood type. Blood that has type O antibodies can be given to anyone.
In Roman numerals the letters I, V, X, L, and C represent the values 1, 5, 10, 50, and 100 respectively. Numbers are formed by combining these letters and adding their values. For example, the Roman numeral for 3 is III, which is three ones added together. The Roman numeral for 12 is XII, which is a ten plus two ones. The Roman numeral for 27 is XXVII, which is two tens plus a five plus two ones.
Given a string with a color value in the format #RRGGBB where RR, GG, and BB are two-digit hexadecimal numbers. (See Welcome to CS - Hex Data & Colors for more details), we want to calculate the perceptual brightness.
We would like to calculate blends of HTML colors in the format #RRGGBB where RR, GG, and BB are two-digit hexadecimal numbers. (See Welcome to CS - Hex Data & Colors for more details).
Our input will be lines of text like #406000 #AAFFBB 80% that have two colors and a percentage. The percentage will describe how much of the second color to use. So #406000 #AAFFBB 80% would mean to give the color #AAFFBB 80% weight and the color #406000 20% weight. We should print a new string in the format #RRGGBB that represents the blended color.