- Read the lab writeup: https://profmarz.com/index.php/cs102/labs/labB
- Lab consists of two parts: Debug and Problem Solving. It is suggested to do the debug first as you will be more familiar with C++'s syntax.

Getting Started

- Read the lab writeup: https://profmarz.com/index.php/cs102/labs/labB
- Lab consists of two parts: Debug and Problem Solving. It is suggested to do the debug first as you will be more familiar with C++'s syntax.

Synopsis

Congratulations for making it past the first lab. Now things will get a little tougher. This lab will let you calculate how many trips you can make around a stack of dollar bills of a certain length. So if I stacked up a few billion dollars, I can find out how many times I can walk back-and-forth the same distance they cover if stacked perfectly.

Constants

There are going to be times in your programs where you want to place (or "hard-code") a value in multiple times. Here is an example of that:
**constants** come in. Observe:

```
int main() {
int val = 4;
int one = val / 4;
cout << val << " / " << 4 << " is equal to 1." << endl;
}
```

This program would output:
`4 / 4 is equal to 1.`

The program's goal is to show that dividing any number by itself makes it equal to 1. However, we have "4" written in 3 different places! So if we wanted to use another number, we would have to change that in 3 different spots each time. This is where ```
const int NUMBER = 4;
int main() {
int val = NUMBER;
int one = val / NUMBER;
cout << val << " / " << NUMBER << " is equal to 1." << endl;
}
```

The output is exactly the same. However, if we wanted to change the number we are dividing by, we can easily just change the value at the top.
Example: Feet to Miles

Let's make a more useful program that converts feet to miles. The result may have decimals. That is where the **double** data type comes into play. It is a number, but it allows decimals. Let's see what this program would look like:

```
#include <iostream>
using namespace std;
int main() {
double feet, miles;
cout << "Enter Feet: ";
cin >> feet;
miles = feet / 5280;
cout << "Total Miles: " << miles << endl;
}
```

If we inserted "124" as the feet, the program's output would look like this:
```
Enter Feet: 124
Total Miles: 0.0234848
```

What is iomanip?

```
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int number1 = 2;
int number2 = 23;
int number3 = 435;
cout << "Number 1: " << setw(4) << right << number1 << endl;
cout << "Number 2: " << setw(4) << right << number2 << endl;
cout << "Number 3: " << setw(4) << right << number3 << endl;
}
```

This program would print out 3 numbers, but it would make sure that the number field is set to a width of 4 characters, and would make sure it would print from the right. Its output would look like this:
```
Number 1: 2
Number 2: 23
Number 3: 435
```

To clarify what I meant, if you set the width to 4 and print from the right, you are given the following room to work with:
```
Number 1:
^^^^
```

Then afterwards, it will print from the right of that field of 4.
```
Number 1: 2
^^^^
```

```
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double value = 0.123456;
cout << fixed << setprecision(2) << value << endl;
}
```

I already spoiled what the result would be:
`0.12`

Why do we need "fixed"? Isn't "setprecision()" good enough? Well... not exactly. If we do not print out in "fixed" notation, C++ will lean toward printing out in scientific notation. Plus then "setprecision" will go toward the number of numbers printed out as opposed to the number of decimal places printed out.
The Lab

To start things off, it is given that a dollar bill is 0.0043 inches thick. This lab requires that the thickness of a dollar bill be a **constant** of the data type "double" named "DOLLAR_BILL_THICKNESS_INCHES". You are also given mathematical functions which are in the lab writeup.

You will input distance that you want to travel (in miles) and then how much money you want to stack up. Then you will calculate how many inches the stack of dollar bills would be if stacked perfectly.**iomanip**. Refer to the lab writeup linked above on what he wants your formatting to look like for the lab.

You will input distance that you want to travel (in miles) and then how much money you want to stack up. Then you will calculate how many inches the stack of dollar bills would be if stacked perfectly.

`(dollars * DOLLAR_BILL_THICKNESS_INCHES)`

Afterwards, you need to convert those inches to feet and store them into a variable, followed by converting the feet into miles. Finally, you will calculate the number of trips you can make around the dollar bills. The following formulas are provided to you for doing this:
```
DOLLAR_FEET = DOLLAR_INCHES / 12.0
DOLLAR_MILES = DOLLAR_FEET / 5280.0
TRIPS = DOLLAR_MILES / TRAVEL_DISTANCE
```

Finally, you will print out the results with cout. However, you have a new secret weapon known as