9.15. Coding Practice¶
Write the Cake
structure, which has instance variables name, color, diameter, and has_icing.
Below is one way to implement the program. We declare the Cake
struct and list the instance
variables in order.
Loading a dynamic question ...
Selecting from: cp_9_AC_2q, cp_9_AC_2q_pp
Write the makeCake
function, which prompts the user for a name,
color, diameter, and whether or not they want icing. The function then
returns the cake.
Below is one way to implement the program. We create a Cake
for the user, read in the user’s input using cin, and return the Cake
.
Loading a dynamic question ...
Selecting from: cp_9_AC_4q, cp_9_AC_4q_pp
Write the editCake
function, which prompts the user for a new name,
color, diameter, and whether or not they want icing. The function modifies
the original cake that is passed in as a parameter. Use the makeCake function
in your implementation to avoid duplicate code!
Below is one way to implement the program. We call makeCake
in editCake
and then set the original cake
equal to the new one.
Loading a dynamic question ...
Selecting from: cp_9_AC_6q, cp_9_AC_6q_pp
Write the Pants
structure, which has instance variables size and material.
Below is one way to implement the program. We declare the Pants
struct and list the instance
variables in order.
Loading a dynamic question ...
Selecting from: cp_9_AC_8q, cp_9_AC_8q_pp
Write the printOutfit
function, which prints out details of the outfit.
The output below should be “Shirt: blue and L; Pants: S and denim; has hat”.
Below is one way to implement the program. We declare the Cake
struct and list the instance
variables in order.
Loading a dynamic question ...
Selecting from: cp_9_AC_10q, cp_9_AC_10q_pp