• SAVE EVERY PROGRAM YOU WRITE ON THE H DRIVE.
• Regular 100/80/60 Quizzes
• Final Exam
Code::Blocks

Code::Blocks is the IDE (Integrated Development Environment) that we will be using to write C++ programs. It is open source and can be downloaded for Windows or Mac.

1. In class notes: Intro to Programming. Compile "Hello World".
2. Hello World with Code::Blocks
3. In class notes: Explanation of "Hello World".
Topics:
• int, double, string
• creating variables
• assigning values
• cin
+, -, *, /
The four steps are:
1. Understand the problem completely.
2. Design the program using a flow chart.
3. Double check the logic of your design.
4. Code.
if statements and if..else
1. Write a calculator program.
2. First ask the user to choose between +, -, *, and /. (Hint, use a string variable)
3. Second then asks the user to enter two numbers (hint, use two doubles).
4. Third then displays the result of the arithmetic calculation in a user friendly manner.

For inspiration, look at some of the calculator examples in the Pickup box > Wear > INT 910 > calculator examples

Topics:
• integer division
• modulus
• casting

In-Class Challenge: Write a program that asks the user to enter an integer between 1 and 1,000,000. Then print the answer to the number divided by 10 and the number modulus 10.
1. Create a new project in codeBlocks and call it calculator2.
2. Copy the code from your first calculator and save it as `calculator2.cpp`.
3. Add the file `calculator2.cpp` to your new project.
5. Modify the calculator program so that the user can enter their name:
1. Put this line of code with your other variable declarations:
`string name;`
2. At the beginning of the program ask them to enter their name:
```cout << "Please enter name: "; getline(cin, name);```
3. Later in the program, address them by name:
```cout << "Hello " << name << "\n"; ```
2. Tutorial 2,
4. Add a do...while loop to your menu, so that if the user chooses an option not on the menu, it prints an error and repeats the menu.
• Chris.com
• Special characters: ", \n, and \
1. Copy `Calculator 2` and save it as a new project called `Calculator3`.
2. Add `fabs(), sqrt(), ceil(), floor(), pow()` from `math.h` to the next version of your calculator.
3. Using a do...while loop, modify your program so that it asks the user if they want to do another calculation. If they answer "Y", it does.
4. Add a cool ASCII Art splash screen.
```
do {
cout << "Please enter the number: ";
cin >> num1;
cout << "\n";

if(cin.good() == 0) {
cout << "You must enter a NUMBER!!!\n";
cin.clear();
cin.ignore(80, '\n');
continue;
}
break;

} while (true);
```
Today you are going to make your Calculator more user friendly. Here is how to do it:

1. Add a splash screen using ascii art.
• Go to Chris.com or Ascii Text Title Generator to look for ascii art. Choose art that is less than 25 lines long and less than 80 characters wide.
• Paste it into the program
• Add `cout "` at the beginning of each line, `\n";` at the end of each line.
• If the ascii art has any `\` characters in it, replace it with `\\`. This will print one backslash.
• If the ascii art has any `"` characters in it, replace it with `\"`. This will print one double quote.
• Run the program and make sure the ascii art looks good. If not, fix it.

3. Clear the screen occasionally using `system("CLS");`. You have to add at the top of your program.
4. Run some old calculators under Examples to see how to use blank space and lines to make output easier to read.
2. Offers the following functions: +, -, *, /, %, absolute value, square root, power, ceiling and floor.
3. If the user chooses a symbol NOT on the menu, it displays an error message, clears the screen, and displays the menu again.
4. It allows the user to repeat the program.
5. It asks for and uses the user's name.
6. It has a splash screen.
7. It has color.
8. It is as user-friendly as possible.
9. It accepts both uppercase and lowercase characters in the menu.
10. If the user types a character when a number is expected, it prints an error and allows the user to reenter a number.
Assessment ( /25):
- Basic Requirements ( /20)
- Awesomeness of the Design ( /5)

Today you will design the Splash Screen (the start up screen at the beginning of your program) for the upcoming project: The Lemonade Stand.

The splash screen can earn you up to 2 out of 10 marks for your personalized Lemonade Stand.

1. Create a new project in CodeBlocks. Instructions can be found here.
2. Add colors.h as a new file to your project. Instructions can be found here.
3. Play a selection of the Lemonade Stands found here: Examples
4. Go to Chris.com and Ascii Title Generator for ascii art.
5. Use creative colour.
6. Recall to animate ASCII Art, first include
`windows.h`
and use the command Sleep to pause for a certain number of milliseconds, followed by a clear screen as shown:
```Sleep(500); // sleeps for 1/2 second system("CLS");```
To animate ASCII Art, first include
`windows.h`
and use the command Sleep to pause for a certain number of milliseconds, followed by a clear screen as shown:
```Sleep(1000); // sleeps for 1 second system("CLS");```

In windows.h

```Beep(523,500); // 523 hertz (C5) for 500 milliseconds
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
```

In windows.h

```
//allows ShowWindow to work, put at top of program, before main
#define _WIN32_WINNT 0x0500

// put at top of main
ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);

```
• Complete as shown in class.
Assessment (/15)
```Basic Stand Completed             /5
- can play a complete game (given in class) without errors
- all numbers are accurate
- no bugs / errors

User-Interface Improvements:   /10
1 mark per improvement that works without errors.
** with up to 3 bonus marks for exceptional creativity and programming **

Examples:
Awesome Splash Screen
Awesome use of color
Appropriate use of sound
Error checking on:
maxDays  (not less than 0)
incomeGoal (not less than 0)
price  (not less than 0, max price)
buyAmounts (not less than 0, OR allows user to sell inventory)
Play Again
Win/Lose Screens
Levels (easy, hard, presets #days and income goal)
Weather
Burglars/Allowance
Improved interface
```
25 multiple choice questions.