See pages 44-51 for review on functions
See pages 86-98 for review on calculations with numbers
You have been introduced to the variable types int (integers) and float (floating point or decimal numbers). There are variations on these types which you will see later. These types, however, all store numbers. If you want to store characters (letters, words etc.) you must use the type char. This type is capable of storing one character (letter, number, punctuation). For example, your program can contain lines like:
If you want to store more than one letter in a given variable (for example your name) you must use an array of characters. For now, you can think of an array of characters as a bunch of characters strung together that can be addressed with one common name. The only difference between the variable holding a single letter versus several letters is that when you declare the variable you must tell the computer how many letters is the maximum that will be stored in the variable. For example if I wanted to declare a variable called name that could hold up to 25 letters I would do it as follows:
I could then use this to store a name and print it out as shown here:
cout<<"Enter your name: ";
The book uses a type called "string" for this same purpose that we will not use just yet. String is not built into C++, and is simply a shorthand way of doing what I have outline here.
Your first assignment is to write a program that is a birthday party planner. This program will need to calculate the amount of supplies needed for the party based on the following information.
Click Here for Hints
Click Here to Download a DOS Version of the Program
You will ask the user for the number of people attending the party. Based on this it will need to calculate the number of sodas, the number of pizzas, the size of the cake, and the cost per person. You should use floating point numbers when making calculations and print out fractional amounts of pizza ,cake and bottles of soda if necessary (i.e. it is ok to tell the person to purchase 1.8 pizzas, and a cake that is 15.4 inches long).
Finally, you will need to enter the names of three people and assign them the roles of purchasing these three items (by printing their names and items out). You should tell them how much money they will need to bring for their items based on the previous calculations.
This program should have comments on almost every line explaining what the program is doing. Additionally, while you may write the program in pairs, each person must explain in their own words how this program works. This explanation should be at least a couple of paragraphs.
This program will be graded on the following factors:
This assignment will be due Friday. Instructions on how to get me a copy of the program will follow.
Back to Home Page