# [PYTHON] Lunar Lander

```#Lunar Lander Simulation
#Kevin Wong - kmw396
#CS164-069 / Lecture B

#this function will ask the user the amount fuel they want to use
valid = False
while not valid:
try:
f = input("Enter units of fuel to use: ")
f = int(f)
# if the user enters anything thats less than 0, it won't accept it.
if f < 0:
print("Cannot use negative fuel.")
valid = False
# if the user enters an amount that doesn't exist, it won't accept it.
elif f > current_fuel:
print("Not enough fuel. Max Fuel:", current_fuel)
# if the user enters the correct amount, it will accept it
elif f >=0 and f <= current_fuel:
return f
# if non-int value, it will ask again.
except ValueError as e:

def play_level(name,gravity,fuel):
altitude = 50 #altitude (m)
velocity = 0 #inital velocity (m/s)
s = 0 #number of seconds passed
T = 0.1 #thruster accerlation (m/s^2)

#prints the stats
print("Entering Level",level)
print("Landing on the",name)
print("Gravity is %.2f m/s^2" %gravity)
print("Inital Altitude:",altitude,"meters")
print("Initial Velocity: %.2f m/s" %velocity)
print("Burning a unit of fuel causes 0.10 m/s slowdown.")
print("Inital Fuel Level:",fuel)
print("\nGO")

#loop for the game
while altitude != 0:
#asks user for the amt. of fuel they want to use
#calculates the velocity
velocity = velocity + gravity + T * f
#calculates the altitude
altitude += velocity
#when user enters amt of fuel they want to use, it will subtract from the total amount available and give back whats left
fuel -= f
#adds 1 to the time counter through every succession
s += 1
#if the altitude is lower than or equal to 0, altitude becomes 0
if altitude <= 0:
altitude = 0
print("After",s,"seconds, the Altitude is %.2f meters, and Velocity is %.2f m/s." %(altitude,velocity))
print("Remaining Fuel:",fuel,"units.")

#if the altitude is 0, the function will run
if altitude == 0:
#a successful landing is where the velocity is between -2 an 2
if velocity <= 2 and velocity >= -2:
print("Landed Successfully.")
final = 0
return final
else:
print("Crashed!")
final = 1
return final

level = 1 #stores level information and starts level at 1

print("Welcome to Lunar Lander Game.")
#it will run the loop until it reaches 11
while level <= 11:
play = input("Do you want to play %d? (yes/no)\n" %level)
if play.lower() == 'yes': #if the user says yes, it will start the game.
#provides necesscary information for each level so the function play_level runs.
if level == 1:
moon = play_level('Moon',-1.622,150)
if moon == 0:
level += 1
elif moon == 1:
level = 1

elif level == 2:
earth = play_level('Earth',-9.81,5000)
if earth == 0:
level += 1
elif earth == 1:
level = 2

elif level == 3:
pluto = play_level('Pluto',-0.42,1000)
if pluto == 0:
level += 1
elif pluto == 1:
level = 3

elif level == 4:
neptune = play_level('Neptune',-14.07,1000)
if neptune == 0:
level += 1
elif neptune == 1:
level = 4

elif level == 5:
uranus = play_level('Uranus',-10.67,1000)
if uranus == 0:
level += 1
elif uranus == 1:
level = 5

elif level == 6:
saturn = play_level('Saturn',-11.08,1000)
if saturn == 0:
level += 1
elif saturn == 1:
level = 6

elif level == 7:
jupiter = play_level('Jupiter',-25.95,1000)
if jupiter == 0:
level += 1
elif jupiter == 1:
level = 7

elif level == 8:
mars = play_level('Mars',-3.77,1000)
if mars == 0:
level += 1
elif mars == 1:
level = 8

elif level == 9:
venus = play_level('Venus',-8.87,1000)
if venus == 0:
level += 1
elif venus == 1:
level = 9

elif level == 10:
mercury = play_level('Mercury',-3.59,1000)
if mercury == 0:
level += 1
elif mercury == 1:
level = 10

elif level == 11:
sun = play_level('Sun',-274.13,50000)
if sun == 0:
level += 1
elif sun == 1:
level = 11

elif play.lower() == 'no': #if the user says no, it will quit and display their stats.
level -= 1
print("Thanks for playing!")
exit()```

# [PYTHON] Sane Libs

```#Sane Libs
#Kevin Wong - kmw396
#CS164-069 / Lecture B

# introduction to program and user input for file
print('Welcome to a fun word replacement game.')
userFile = input('Enter the name of the file to use:\n')

# tests file and gracefully exits if the file is invalid
try:
file = open(userFile,"r")
except:
exit()

# memory locations for output and vowels
output = ''
vowel = ['a','e','i','o','u']

# for loop for splitting the file
for line in file:
lineSplit = line.split()

# for loop for checking each invidual word on each line
for word in lineSplit:

if (word[0] == '['):

# if statement checks for brackets with punctuation
if word[len(word) - 2] == ']':
userInput = ''
# displays the word inside of bracket. ex: [verb]. = verb and not verb].
bracket = word[1: (len(word) - 2)]
# gets length of the word and subtract 1 to get the index for the punctuation
punct = word[len(word) - 1]

#checks if the first letter is a vowel then decides which question to give
if word[1] in vowel:
userString = 'Please give an ' + bracket + '\n'
userInput = input(userString)
else:
userString = 'Please give a ' + bracket + '\n'
userInput = input(userString)
# gets all of the input, adds it together with punctuation and proper spacing.
output += userInput + punct + ' '

# if statement checks for brackets without punctuation
elif word[len(word) - 1] == ']':
userInput = ''
# displays the word inside of the bracket. ex: [noun] = noun not noun]
bracket = word[1: (len(word) - 1)]

#checks if the first letter is a vowel then decides which question to give
if word[1] in vowel:
userString = 'Please give an ' + bracket + '\n'
userInput = input(userString)
else:
userString = 'Please give a ' + bracket + '\n'
userInput = input(userString)
# gets all of the input, adds it together with proper spacing.
output += userInput + ' '

# adds the rest of the story together
else:
output += word + ' '

# output
print('-------------------')
print(output)```

# [PYTHON] Monty Hall Game

```#Monty Hall Analysis
#Kevin Wong - kmw396
#CS164-069 / Lecture B
import random # we need to initalize the python in-built random library

# this will ask the user to enter a seed for testing purposes. It has a try & except catch in case the user enters a non-interger. It will gracefully exit the program if it's a non-integer.
seed = input("Enter Random Seed:\n")
try:
seed = int(seed)
random.seed(seed)
except ValueError:
print(seed, "is not a number!")
exit()

print("Welcome to Monty Hall Analysis")
print("Enter \'exit\' to quit.")

# This is the input for the number of times the Monty Hall Analysis test should run. It has a try & except catch in case the user enters an non-interger. It also allows the user to exit the program.
numberTest = input("How many tests should we run?\n")
if numberTest == 'exit':
exit()
valid = False
while not valid:
try:
numberTest = int(numberTest)
valid = True
except ValueError:
numberTest = input("Please enter a number:\n")
if numberTest == 'exit':
exit()

# These variables are designed to hold the values of stsy and switch if you're testing more than 10 times.
stayRatio = 0
switchRatio = 0

# Initalize list for Doors.
Door = ['G', 'C', 'G']

while numberTest != 'exit': #checks if the user enters exit

if numberTest <= 10: # runs the program with extra output if the number of tests is less than 10
for i in range (1, numberTest + 1):
random.shuffle(Door) # shuffles the list of doors
playerSelect = random.randint(0,2) # player picks door using random
montySelect = random.randint(0,2) # monty picks door using random
# monty won't pick a door if the player picked it already or if the door is 'C'
while montySelect == playerSelect or montySelect == Door.index('C'):
montySelect = random.randint(0,2)
# this will tell the print function to either print "not switch" or "switch" based on if the player has a Car or a Goat. This will add a 1 to the respective variables if the player is correct or incorrect
if Door[playerSelect] == 'C':
switch = 'not switch'
stayRatio = stayRatio + 1
if Door[playerSelect] == 'G':
switch = 'switch'
switchRatio = switchRatio + 1
# since python's random numbers start at 0, we need to add 1 to it.
playerSelect += 1
montySelect += 1
print("Game %d" % (i)) #prints "Game 'X'"
print("Doors:",Door) #prints shuffled doors
print("Player Selects: Door",playerSelect) #prints the door the player selected
print("Monty Selects: Door",montySelect) #prints the door monty selected
print("Player should",switch,"to win.") #tells you if you should switch or not switch
stayFinal = (stayRatio / numberTest * 100) # calculates the ratio of stay
switchFinal = (switchRatio / numberTest * 100) # calculates the ratio of switching
print("Stay Won","%.1f%%" % stayFinal,"of the time.") #prints final stayratio
print("Switch Won","%.1f%%" % switchFinal,"of the time.") #prints final switchratio

if numberTest > 10: # runs the program without extra output if the number of tests is greater than 10
for i in range(1, numberTest + 1):
random.shuffle(Door) # shuffles the list of doors
playerSelect = random.randint(0,2) # player picks door using random
montySelect = random.randint(0,2) # monty picks door using random
# monty won't pick a door if the player picked it already or if the door is 'C'
while montySelect == playerSelect or montySelect == Door.index('C'):
montySelect = random.randint(0,2)
# this will add a 1 to the respective variables if the player is correct or incorrect
if Door[playerSelect] == 'C':
stayRatio = stayRatio + 1
if Door[playerSelect] == 'G':
switchRatio = switchRatio + 1
stayFinal = (stayRatio / numberTest * 100) # calculates the ratio of stay
switchFinal = (switchRatio / numberTest * 100) # calculates the ratio of switching
print("Stay Won","%.1f%%" % stayFinal,"of the time.") #prints final stayratio
print("Switch Won","%.1f%%" % switchFinal,"of the time.") #prints final switchratio
break
if numberTest == 'exit':
exit()```

# [PYTHON] Student Loan Calculator

```#Student Loan Calculator
#Kevin Wong - kmw396
#CS164-069 / Lecture B
Principle = float(input('How much do you want to borrow? (no commas) \n'))
# Ask user how much they want to borrow and assigns to Principle variable.
years = int(input('How many years do you need on the loan?\n'))
# Asks how many years they would like to take out on the loan
#Variables used for each loan
#SfdLoan - Subsidized Federal Direct Loan
#UfdLoan - Unsubsidized Federal Direct Loan
#plusLoan - Unsubsidized PLUS Loan
# ==== Subsidized Federal Direct Loan ====
print("=======================================================") #just to add some design :)
print("SUBSIDIZED FEDERAL DIRECT LOAN") #prints out what type of loan its calculating
print("=======================================================")
SfdLoan = (Principle*0.034)/(12*(1-(1+(0.034/12))**(-years*12))) # This calculates the monthly payment for the loan
print("You will pay","\$%.2f" % SfdLoan,"every month for this loan.\n") # I used modulus floating point 2 over round(var,x) since you can add a "\$" symbol in front of your number
SfdLoanBal = SfdLoan * 12 * years # This calculates the total balance that will you pay for the loan before fees
print("The total amount paid for this loan will be","\$%.2f" % SfdLoanBal,"over",years,"years.")
SfdLoanInterest = SfdLoanBal - Principle # This calculates the interest paid before your principle
print("The amount of interest paid on this loan will be","\$%.2f" % SfdLoanInterest,"over",years,"years.\n")
SfdLoanFee = Principle * 0.01051 # This calculates the fee for the loan based on the principle.
print("When a Subsizded Federal Direct Loan is taken out, you are\ncharged a fee based on the Principle. Your fee will be","\$%.2f" % SfdLoanFee,"\n")
print("The total amount paid over the principle will be:","\$%.2f" % (SfdLoanInterest + SfdLoanFee)) # This will calculate & print the interest/fees before the principle
print("The total amount paid including fees will be:","\$%.2f" % (SfdLoanBal + SfdLoanFee)) # This will calculate & print the entire cost of the loan including fees.
print("=======================================================")
# ==== Unsubsidized Federal Direct Loan ====
print("UNSUBSIDIZED FEDERAL DIRECT LOAN")
print("=======================================================")
newPrinciple = Principle * (1 + 0.068 * 4.25) # This will calculate the new principle for the loan since interest acculumates as your in school for this loan
UfdLoan = (newPrinciple*0.068)/(12*(1-(1+(0.068/12))**(-years*12))) # This calculates the monthly payment for the loan
print("You will pay","\$%.2f" % UfdLoan,"every month for this loan.\n")
UfdLoanBal = UfdLoan * 12 * years # This calculates the total balance that will you pay for the loan before fees
print("The total amount paid for this loan will be","\$%.2f" % UfdLoanBal,"over",years,"years.")
UfdLoanInterest = UfdLoanBal - Principle # This calculates the interest paid before your principle
print("The amount of interest paid on this loan will be","\$%.2f" % UfdLoanInterest,"over",years,"years.\n")
UfdLoanFee = Principle * 0.01051 # This calculates the fee for the loan based on the principle.
print("When a Unsubsizded Federal Direct Loan is taken out, you are\ncharged a fee based on the Principle. Your fee will be","\$%.2f" % UfdLoanFee,"\n")
print("The total amount paid over the principle will be:","\$%.2f" % (UfdLoanInterest + UfdLoanFee)) # This will calculate & print the interest/fees before the principle
print("The total amount paid including fees will be:","\$%.2f" % (UfdLoanBal + UfdLoanFee)) # This will calculate & print the entire cost of the loan including fees.
print("=======================================================")
# ==== Unsubsidized Plus Loan ====
print("UNSUBSIDIZED PLUS LOAN")
print("=======================================================")
newPrinciple = Principle * (1 + 0.079 * 4.25) #This will calculate the new principle for the loan since interest acculumates as your in school for this loan
plusLoan = (newPrinciple*0.079)/(12*(1-(1+(0.079/12))**(-years*12)))
print("You will pay","\$%.2f" % plusLoan,"every month for this loan.\n")
plusLoanBal = plusLoan * 12 * years # This calculates the total balance that will you pay for the loan before fees
print("The total amount paid for this loan will be","\$%.2f" % plusLoanBal,"over",years,"years.")
plusLoanInterest = plusLoanBal - Principle # This calculates the interest paid before your principle
print("The amount of interest paid on this loan will be","\$%.2f" % plusLoanInterest,"over",years,"years.\n")
plusLoanFee = Principle * 0.04204 # This calculates the fee for the loan based on the principle.
print("When a Unsubsidized PLUS Loan is taken out, you are\ncharged a fee based on the Principle. Your fee will be","\$%.2f" % plusLoanFee,"\n")
print("The total amount paid over the principle will be:","\$%.2f" % (plusLoanInterest + plusLoanFee)) # This will calculate & print the interest/fees before the principle
print("The total amount paid including fees will be:","\$%.2f" % (plusLoanBal + plusLoanFee)) # This will calculate & print the entire cost of the loan including fees.
print("=======================================================")```

# [C++] Casino Game

```#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void roulette();
void blackjack();
void dice();

int main()
{
int age;
cout << "Welcome to the Casino!" << endl; // Welcomes User
cin >> age; // Age Input
if (age < 21) // If less than 21, you cannot play.
{
cout << "Sorry, you are not old enough to gamble." << endl;
return 0;
}
else if (age > 21) // If 21 or older, you can play.
{
int gameChoice; // Initalize gameChoice
cout << "Thanks! What game would you like to play?" << endl; // Game Options
cout << "1. Roulette" << endl;
cout << "2. Blackjack" << endl;
cout << "3. 7-11-Doubles" << endl;
cin >> gameChoice; // Game Option Input
if (gameChoice == 1) // Choice 1
{
roulette();
}
else if (gameChoice == 2) // Choice 2
{
blackjack();
}
else if (gameChoice == 3) // Choice 3
{
dice();
}
}
return 0;
}

void roulette()
{
double winnings; // Winnings Calculator
int randomNumber; // The Board
int x = 2, y = 1; // Odds and Events
int betChoice; // Bet on Colors or Numbers?
double betAmount; // How much to bet?
cout << "How much would you like to bet?" << endl;
cin >> betAmount;
cout << "Do you want to bet on colors or numbers?" << endl;
cout << "1. Colors" << endl;
cout << "2. Numbers" << endl;
cin >> betChoice;
srand(time(0)); // Random Number Generator
randomNumber = rand() % 36;
if (betChoice == 1)
{
int betColor;
cout << "What color would you like to bet on?" << endl;
cout << "1. Black (Evens)" << endl;
cout << "2. Red (Odds)" << endl;
cout << "3. Green (0)" << endl;
cin >> betColor;
if (betColor == 1) // Black (evens)
{
while (x < 36)
{
if (x == randomNumber)
{
cout << "You landed on Black! Your number was " << randomNumber << "." << endl;
winnings = betAmount * 2;
cout << "You're the lucky winner! You won \$" << winnings << " USD." << endl;
}
x = x + 2;
}
}
else if (betColor == 2) // Red (odds)
{
while (y < 36)
{
if (y == randomNumber)
{
cout << "You landed on Red! Your number was " << randomNumber << "." << endl;
winnings = betAmount * 2;
cout << "You're today's lucky winner! You won \$" << winnings << " USD." << endl;
}
y = y + 2;
}
}
else if (betColor == 3) // Green (0)
{
if (randomNumber == 0)
{
cout << "You landed on Green! Your number was " << randomNumber << "." << endl;
winnings = betAmount * 2;
cout << "You're the lucky winner for today! You won \$" << winnings << " USD." << endl;
}
}
}
else if (betChoice == 2) // Numbers
{
int betNumber;
cout << "Please guess a number between 0 and 36: " << endl; // Please Guess Question
cin >> betNumber;
while (betNumber < 0 || betNumber > 36) // Keeps within 0 to 36 Range
{
cout << "Sorry, please choose a number between 0 and 36." << endl;
cin >> betNumber;
}
if (betNumber == randomNumber)
{
cout << "You landed on " << randomNumber << "." << endl;
winnings = betAmount * 35;
cout << "Congratulations! You are the lucky winner! You won " << winnings << " USD." << endl;
}
else if (betNumber != randomNumber)
{
cout << "You landed on " << randomNumber << "." << endl;
cout << "Sorry! You lost. :(" << endl;
}
}
}

void blackjack()
{
double winnings; // Winnings Calculator
int choice; // Player Choice
int randomCard; // The Cards
int playerSum = 0, dealerSum = 0; // Player & Dealer
double betAmount; // Bet Amount
cout << "How much would you like to bet?" << endl;
cin >> betAmount;
randomCard =  1 + rand() % 11; // Random Number Generator for Player
playerSum = playerSum + randomCard; // Calculate Card
randomCard = 1 + rand() % 11; // Random Number Generator for Player
playerSum = playerSum + randomCard; // Calculate Card
cout << "The Player's Hand: " << playerSum << endl;
randomCard = 1 + rand() % 11; // Random Number Generator for Dealer
dealerSum = dealerSum + randomCard; // Calculate Card
randomCard = 1 + rand() % 11; // Random Number Generator for Dealer
dealerSum = dealerSum + randomCard; // Calculate Card
cout << "The Dealer's Hand: " << dealerSum << endl;
winnings = betAmount * 2; // Winnings Multipler
if (playerSum == 21)
{
cout << "You beat the dealer and have 21! You win: \$" << winnings << endl;
}
else if (dealerSum == 21)
{
cout << "You lost to the dealer and they have 21. :(" << endl;
}
else
{
while (playerSum < 21)
{
if (dealerSum <= 17)
{
cout << "Dealer Hits" << endl;
randomCard = 1 + rand() % 11;
dealerSum = dealerSum + randomCard;
cout << "The Dealer's Hand: " << dealerSum << endl;
if (dealerSum > 21)
{
cout << "You beat the dealer. They exceeded 21." << endl;
}
}
else if (dealerSum >= 17)
{
cout << "The Dealer Stays" << endl;
}
else if (dealerSum < 21)
{
cout << "The Dealer Stays" << endl;
}
cout << "What would you like to do?" << endl; // Option
cout << "1. Hit" << endl; // Hit
cout << "2. Stay" << endl; // Stay
cin >> choice;
if (choice == 1) // Option 1 - Hit
{
randomCard = 1 + rand() % 12; // Random Number Generator
playerSum = playerSum + randomCard; // Calculate Cards
cout << "The Player's Hand: " << playerSum << endl;
if (playerSum > 21)
{
cout << "You lost to the dealer. You exceeded 21." << endl;
}
}
else if (choice == 2) // Option 2 - Stay
{
if (dealerSum < playerSum)
{
cout << "You beat the dealer and won! You win: \$" << winnings << endl;
}
else if (dealerSum > playerSum)
{
cout << "The Dealer Wins! You lost :(" << endl;
}
}
}
}
}

void dice()
{
double winnings; // Winnings Calculator
int randomNumber1, randomNumber2; // Dice 1 and Dice 2
double betAmount; // Bet Amount
cout << "How much would you like to bet?" << endl;
cin >> betAmount;
randomNumber1 = rand() % 6 + 1; // Dice 1
randomNumber2 = rand() % 6 + 1; // Dice 2
cout << "Your first dice was a " << randomNumber1 << "." << endl;
cout << "Your second dice was a " << randomNumber2 << "." << endl;
if(randomNumber1 + randomNumber2 == 7) // If 7, win!
{
cout << "Congrautlations! You won!" << endl;
winnings = betAmount * 2;
cout << "You won: " << winnings << " USD" << endl;
}
else if (randomNumber1 + randomNumber2 == 11) // If 11, win!
{
cout << "Congrautlations! You won!" << endl;
winnings = betAmount * 2;
cout << "You won: " << winnings << " USD" << endl;
}
else if (randomNumber1 == randomNumber2) // If Dice 1 = Dice 2, win!
{
cout << "Congrautlations! You won!" << endl;
winnings = betAmount * 2;
cout << "You won: " << winnings << " USD" << endl;
}
else if (randomNumber1 != randomNumber2) // Anything else, lose :(
{
cout << "Sorry! You lost :(" << endl;
}
}```

# [C++] Guessing Game

```#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
int guess;
int number;
srand(time(0));
number = 1 + (rand() % 100);
do
{
cout << "Guess a number" << endl;
cin >> guess;
if (guess == number)
{
cout << "Congrats! Your guess is correct!" << endl;
}
else if (guess > number)
{
cout << "Incorrect. Your guess is too high!" << endl;
}
else if (guess < number)
{
cout << "Incorrect. Your guess is too low!" << endl;
}
} while (guess < number || guess > number);
return 0;
}
```

# [C++] Large Number Array

```#include <iostream>
using namespace std;

void maxint (int array[], int size);

int main()
{
int n;
const int x = 0;
int array[x];
cout << "How many elements do you want your array to hold?" << endl;
cin >> n;
maxint(array, n);
return 0;
}
void maxint(int array[], int size)
{
int maxE = 0;
cout << "Please enter " << size << " elements for the array:" << endl;
for (int x = 0; x < size; x++)
{
if (maxE > array[x]) {
maxE = array[x]
}
}
cout << "The largest number is: " << maxE << endl;
}```

# [C++] Restaurant Bill Calculator

Designed after Pizzaeria Vetri in Philadelphia, PA

```#include <iostream>
#include <string>
using namespace std;

int main()
{
string customerName;
int guests;
int baseDrink;
int flavorDrink;
int baseDrink1 = 0;
int flavorDrink1 = 0;

cout << "Welcome to Pizzeria Vetri" << endl;
cin >> customerName;
cout << "Welcome to our resturant, " << customerName << "!" << endl;
cout << "May we ask, how many guests are at the table?" << endl;
cin >> guests;
while(baseDrink1 < guests) {
cout << "Thanks! What kind of drinks would you guys like?" << endl;
cout << "We currently only offer Coca-Cola Remix products." << endl;
cout << "What would you like you Base Drink to be?" << endl;
cout << "1. Coke - \$2.49" << endl;
cout << "2. Diet Coke - \$2.49" << endl;
cout << "3. Sprite - \$2.49" << endl;
cout << "4. Fanta - \$2.49" << endl;
cout << "5. Barq's Root Beer - \$2.99" << endl;
cout << "6. Seagram's Ginger Ale - \$2.99" << endl;
cout << "7. Minute Maid - \$1.99" << endl;
cout << "8. Dasani - \$1.49" << endl;
cout << "9. Mellow Yellow - \$1.99" << endl;
cout << "10. fruitWater - \$1.49" << endl;
cin >> baseDrink;
baseDrink1++;
}
while(flavorDrink1 < guests) {
cout << "Thanks! What kind of flavor would you like?" << endl;
cout << "1. Original" << endl;
cout << "2. Cherry" << endl;
cout << "3. Orange" << endl;
cout << "4. Grape" << endl;
cout << "5. Lemon" << endl;
cin >> flavorDrink;
cout << "Thank You, " << customerName << "!" << endl;
flavorDrink1++;
}
cout << "Now, what kind of entrees would your guests like?" << endl;
cout << "11. Classic Pizza - \$3.49 Slice" << endl;
cout << "12. Melanzana Pizza - \$3.99 Slice" << endl;
cout << "1. Arugula Salad - \$5.49" << endl;
}```

# [C++] Toll Booth

```#include <iostream>
using namespace std;

class tollBooth
{
private:
int vehicleTotal; // Holds Data for Paying and Non-Paying Vehicles
double moneyTotal; // Holds Data for Money Collected
public:
tollBooth():vehicleTotal(0),moneyTotal(0)
{
}
void payTotal()
{
vehicleTotal++; // Increments Total for Paying Vehicles
moneyTotal = moneyTotal + 0.50; // Adds 50c into cashTotal
}
void noPayTotal()
{
vehicleTotal++; // Increments Total for Non-Paying Vehicles
}
void displayTotals()
{
cout << "TOTAL CARS PASSED: " << vehicleTotal << endl;
cout << "MONEY TOTAL:" << moneyTotal << endl;
}
};

int main()
{
int c;
tollBooth ch;
do
{
cout << "Press 1 for a Paying Vehicle" << endl;
cout << "Press 2 for a Non-Paying Vehicle" << endl;
cout << "Press 3 to Display a Total" << endl;
cin >> c;
if (c == 1) // Increment Paying
{
ch.payTotal();
}
if (c == 2) // Increment No Pay
{
ch.noPayTotal();
}
if (c == 3) // Display Totals
{
ch.displayTotals();
}
} while (c == 1 | c==3);
return 0;
}```

```#include <iostream>
using namespace std;

class time
{
private:
int hr, min, sec;
public:
time():hr(0), min(0), sec(0)
{
}
time(int h, int m, int s) :hr(h), min(m), sec(s)
{
}
{
hr = t1.hr + t2.hr;
min = t1.min + t2.min;
sec = t1.sec + t2.sec;
if (sec >= 60)
{
sec = sec - 60;
min = min + 1;
}
if (min >= 60)
{
min = min - 60;
hr = hr + 1;
}
}
void display() const
{
cout << "The Time Is: " << hr << ":" << min << ":" << sec << endl;
}
};
int main()
{
const time t1(3, 15, 20), t2(6, 44, 40);
time t3;
t3.display();
return 0;
}```

# [C++] Square Circle Triangle

```#include <iostream>
using namespace std;
void circle();
void triangle();
void square();

int main()
{
int choice;
cout << "Select the shape you would like to solve for: " << endl;
cout << "1. Circle" << endl;
cout << "2. Triangle" << endl;
cout << "3. Square" << endl;
cin >> choice;
if (choice == 1)
{
circle();
}
else if(choice == 2)
{
triangle();
}
else if(choice == 3)
{
square();
}
return 0;
}
void circle()
{
const double pi = 3.14;
cout << "You have selected: Circle" << endl;
cout << "Please enter the radius of the circle: " << endl;
circumference = 2 * pi * radius;
cout << "The Area of a Circle is: " << area << endl;
cout << "The Circumference of a Circle is: " << circumference << endl;
}
void triangle()
{
double area, height, base;
cout << "You have selected: Triangle" << endl;
cout << "Please enter the height of the triangle: " << endl;
cin >> height;
cout << "Please enter the base of the triangle: " << endl;
cin >> base;
area = .5 * base * height;
cout << "The Area of the Triangle is: " << area << endl;
}
void square()
{
double side, area, perimeter;
cout << "You have selected: Square" << endl;
cout << "Please enter the side of the square: " << endl;
cin >> side;
area = side * side;
perimeter = 4 * side;
cout << "The Area of the Square is: " << area << endl;
cout << "The Preimeter of the Square is: " << perimeter << endl;
}```