diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2022-09-09 15:22:01 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 15:22:01 -0600 |
commit | e2ab34e60f544d9d6902fe3eb8e0947009234955 (patch) | |
tree | 0a93bb11a63e8dc62663925f7f90f41576229dc2 /hw2 | |
parent | 6ae81ee58a1d2ffa8f8f5fe9dc45a8f064c31c4d (diff) |
Diffstat (limited to 'hw2')
-rw-r--r-- | hw2/almondMilk.cpp | 4 | ||||
-rw-r--r-- | hw2/calcSigmoid.cpp | 6 | ||||
-rw-r--r-- | hw2/convertCurrency.cpp | 6 | ||||
-rw-r--r-- | hw2/helloWorld.cpp | 2 | ||||
-rw-r--r-- | hw2/helloYou.cpp | 4 | ||||
-rw-r--r-- | hw2/snowfall.cpp | 1 |
6 files changed, 12 insertions, 11 deletions
diff --git a/hw2/almondMilk.cpp b/hw2/almondMilk.cpp index 77bc61e..ffe3bf6 100644 --- a/hw2/almondMilk.cpp +++ b/hw2/almondMilk.cpp @@ -12,12 +12,12 @@ int main() { double side_len = 0;
double height = 0;
double volume = 0;
-
+ // User input
cout << "What is the side length of the base of the carton in inches?\n";
cin >> side_len;
cout << "What is the height of the carton in inches?\n";
cin >> height;
- volume = (side_len*side_len)*height*0.55;
+ volume = (side_len*side_len)*height*0.55; // Calculate and convert to ounces
cout << "The carton has a volume of " << fixed << setprecision(1) << volume<<" ounces.";
return 0;
}
\ No newline at end of file diff --git a/hw2/calcSigmoid.cpp b/hw2/calcSigmoid.cpp index 723ec66..e1ac3ed 100644 --- a/hw2/calcSigmoid.cpp +++ b/hw2/calcSigmoid.cpp @@ -4,16 +4,16 @@ // Homework 2 - Problem 6
#include<iostream>
-#include<cmath>
+#include<cmath> // Required for using the exp function
using namespace std;
int main() {
double x = 0;
double sigmoid = 0;
- cout << "Enter a value for x:\n";
+ cout << "Enter a value for x:\n"; // User input
cin >> x;
sigmoid = 1/(1+(exp(-x)));
- cout << "The sigmoid for x=" << x << " is " << sigmoid;
+ cout << "The sigmoid for x=" << x << " is " << sigmoid; // prints our sigmoid function
return 0;
}
\ No newline at end of file diff --git a/hw2/convertCurrency.cpp b/hw2/convertCurrency.cpp index 1d19136..8a31340 100644 --- a/hw2/convertCurrency.cpp +++ b/hw2/convertCurrency.cpp @@ -11,10 +11,10 @@ int main() { int gems = 0, gold = 0, bolts = 0;
cout << "Enter the number of Bolts:\n";
cin >> bolts;
- gold = bolts/23;
- bolts = bolts % 23;
+ gold = bolts/23; // Gets the number of gold coins we can convert
+ bolts = bolts % 23; // Calculates the total umber of bolts you cannot use to convert
gems = gold / 13;
gold = gold % 13;
- cout << gems << " Gem(s) " << gold << " GoldCoin(s) " << bolts << " Bolt(s)";
+ cout << gems << " Gem(s) " << gold << " GoldCoin(s) " << bolts << " Bolt(s)"; // Outputs
return 0;
}
\ No newline at end of file diff --git a/hw2/helloWorld.cpp b/hw2/helloWorld.cpp index f4b5587..500787c 100644 --- a/hw2/helloWorld.cpp +++ b/hw2/helloWorld.cpp @@ -8,5 +8,5 @@ using namespace std; int main() { - cout << "Hello, World!"; + cout << "Hello, World!"; // Prints Hello, World } diff --git a/hw2/helloYou.cpp b/hw2/helloYou.cpp index 98f06ce..8f0dbbb 100644 --- a/hw2/helloYou.cpp +++ b/hw2/helloYou.cpp @@ -10,7 +10,7 @@ using namespace std; int main() {
string name;
cout << "Please enter your name below:\n";
- cin >> name;
- cout << "Hello, " << name << "!";
+ cin >> name; // Takes user input
+ cout << "Hello, " << name << "!"; // Prints user's input
return 0;
}
\ No newline at end of file diff --git a/hw2/snowfall.cpp b/hw2/snowfall.cpp index 2d54a90..5bbff8a 100644 --- a/hw2/snowfall.cpp +++ b/hw2/snowfall.cpp @@ -12,6 +12,7 @@ int main() { cout << "How many days in the future would you like a prediction for?\n";
cin >> num_days;
+ // Takes initial snow, adds the expected snowfall and subtracts the expected melted snow
breck = 25+(10*num_days)-(5*num_days);
vail = 28+(14*num_days)-(2*num_days);
copper = 40+(5*num_days)-(3*num_days);
|