Skip to content

Commit 388bb29

Browse files
committed
Upload Existing Code
1 parent 504d9c2 commit 388bb29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6866
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Joel Brigida
3+
* COP 3014-003
4+
* Dr. Sareh Taebi
5+
* Assignment 0
6+
*/
7+
8+
#include <iostream>
9+
10+
using namespace std;
11+
12+
int main()
13+
{
14+
15+
cout << "We will make the Fall 2020 semester at FAU a great success!!" << endl;
16+
17+
return 0;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Joel Brigida
3+
* COP 3014-003
4+
* Dr. Sareh Taebi
5+
* Assignment #1
6+
*/
7+
8+
#include <iostream>
9+
10+
using namespace std;
11+
12+
int main()
13+
{
14+
15+
// Part a) Integer type input variable declarations
16+
int num_quarters, num_nickels, num_dimes;
17+
18+
//Program Inputs: number of quarters (num_quarters), number of dimes (num_dimes), and number of nickels (num_nickels
19+
20+
// Purpose of program and informative user messages
21+
cout << "=> Pocket Change Counter for Quarters, Dimes, and Nickels <=\n\n";
22+
23+
// Part b) proper prompting to user
24+
cout << "At each one of the 3 prompts, please input an integer quantity for the number of coins.\n\n";
25+
26+
// 1st output meesage to user
27+
cout << "How many quarters are in your pocket? ";
28+
29+
// Part b) 1st program input / user prompt - the number of quarters
30+
cin >> num_quarters;
31+
32+
// 2nd output message to user
33+
cout << "\nHow many dimes are in your pocket? ";
34+
35+
/// Part b) 2nd program input - the number of dimes
36+
cin >> num_dimes;
37+
38+
// 3rd output meesage to user
39+
cout << "\nHow many nickels are in your pocket? ";
40+
41+
// Part b) 3rd program input - the number of nickels
42+
cin >> num_nickels;
43+
44+
// Part c) Integer type output variable declaration Expected output = total value of the of coins in cents
45+
int total_cents;
46+
47+
/** Part d) "How do you relate the inputs to the output?"
48+
49+
The inputs are the integer quantity of individual nickels, dimes, and quarters in the users pocket. The desired output is a total value
50+
of all the coins in cents. Since the inputs are numbers of individual coins (num_quarters, num_dimes, num_nickels), each separate coin quantity
51+
must be multiplied by its value in cents. These 3 separate total quantities (denominated in cents) must be calculated 1st (which is why they
52+
are in parenthesis), then all added together to get the total value in cents output. The 3 individual values of quarters, nickels, and
53+
dimes are all added up and the stored into the variable "total_cents"
54+
*/
55+
56+
// Also Part d) This is the algorithm to solve the problem
57+
total_cents = (num_quarters * 25) + (num_dimes * 10) + (num_nickels * 5);
58+
59+
// Part e) Informative output statement to user indicating total value of coins in cents
60+
cout << "\n\nThe coins in your pocket are worth a total of " << total_cents << " cents.\n\n";
61+
62+
return 0;
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
/**
2+
* Joel Brigida
3+
* COP 3014-003
4+
* Dr. Sareh Taebi
5+
* September 18, 2020
6+
* Assignment 2: Sum and Average calculator
7+
*/
8+
9+
#include <iostream>
10+
11+
using namespace std;
12+
13+
void Q1(); // Void function for calculator
14+
void Q2(); // Alternate way of doing it with input while loop
15+
16+
17+
int main()
18+
{
19+
20+
//Q1();
21+
Q2();
22+
23+
return 0;
24+
25+
}
26+
27+
void Q1()
28+
{
29+
30+
int num1, num2, num3, num4, num5, num6, num7, num8, num9, num10; // user input variables.
31+
char exit_status; // Variable for repeating calculator do-while loop
32+
33+
do {
34+
35+
int pos_counter = 0; // counters to keep track of the # of positive and non-positive integers.
36+
int non_pos_counter = 0; // We assume Zero is not a Positive Integer as in Discrete Math set theory.
37+
int sum_positive = 0; // sum variables for sum calculations.
38+
int sum_non_pos = 0;
39+
int sum_all_nums = 0;
40+
double avg_positive = 0; // average variables for average calculations.
41+
double avg_non_pos = 0;
42+
double avg_all_nums = 0;
43+
44+
cout << "\t=> Sum and Average Calculator <=" << endl << endl;
45+
46+
cout << "Please enter any 10 integers each separated by a space: " << endl;
47+
cin >> num1 >> num2 >> num3 >> num4 >> num5 >> num6 >> num7 >> num8 >> num9 >> num10; // User Entry of variables all at once.
48+
49+
cout << endl;
50+
51+
// 10 if-else conditions, one for each user entered variable,
52+
// which classifies each user input into the proper category.
53+
if (num1 > 0)
54+
{
55+
sum_positive = sum_positive + num1;
56+
pos_counter++;
57+
}
58+
else
59+
{
60+
sum_non_pos = sum_non_pos + num1;
61+
non_pos_counter++;
62+
}
63+
64+
if (num2 > 0)
65+
{
66+
sum_positive = sum_positive + num2;
67+
pos_counter++;
68+
}
69+
else
70+
{
71+
sum_non_pos = sum_non_pos + num2;
72+
non_pos_counter++;
73+
}
74+
75+
if (num3 > 0)
76+
{
77+
sum_positive = sum_positive + num3;
78+
pos_counter++;
79+
}
80+
else
81+
{
82+
sum_non_pos = sum_non_pos + num3;
83+
non_pos_counter++;
84+
}
85+
86+
if (num4 > 0)
87+
{
88+
sum_positive = sum_positive + num4;
89+
pos_counter++;
90+
}
91+
else
92+
{
93+
sum_non_pos = sum_non_pos + num4;
94+
non_pos_counter++;
95+
}
96+
97+
if (num5 > 0)
98+
{
99+
sum_positive = sum_positive + num5;
100+
pos_counter++;
101+
}
102+
else
103+
{
104+
sum_non_pos = sum_non_pos + num5;
105+
non_pos_counter++;
106+
}
107+
108+
if (num6 > 0)
109+
{
110+
sum_positive = sum_positive + num6;
111+
pos_counter++;
112+
}
113+
else
114+
{
115+
sum_non_pos = sum_non_pos + num6;
116+
non_pos_counter++;
117+
}
118+
119+
if (num7 > 0)
120+
{
121+
sum_positive = sum_positive + num7;
122+
pos_counter++;
123+
}
124+
else
125+
{
126+
sum_non_pos = sum_non_pos + num7;
127+
non_pos_counter++;
128+
}
129+
130+
if (num8 > 0)
131+
{
132+
sum_positive = sum_positive + num8;
133+
pos_counter++;
134+
}
135+
else
136+
{
137+
sum_non_pos = sum_non_pos + num8;
138+
non_pos_counter++;
139+
}
140+
141+
if (num9 > 0)
142+
{
143+
sum_positive = sum_positive + num9;
144+
pos_counter++;
145+
}
146+
else
147+
{
148+
sum_non_pos = sum_non_pos + num9;
149+
non_pos_counter++;
150+
}
151+
152+
if (num10 > 0)
153+
{
154+
sum_positive = sum_positive + num10;
155+
pos_counter++;
156+
}
157+
else
158+
{
159+
sum_non_pos = sum_non_pos + num10;
160+
non_pos_counter++;
161+
}
162+
163+
sum_all_nums = num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10; // sum of all numbers calculation
164+
avg_all_nums = (num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10) / 10.0; // average of all numbers calculation
165+
166+
if (pos_counter > 0) // run-time error prevention
167+
{
168+
avg_positive = static_cast <double> (sum_positive) / pos_counter; // positive average calculation
169+
}
170+
else avg_positive = 0.0;
171+
172+
if (non_pos_counter > 0) // run-time error prevention
173+
{
174+
avg_non_pos = static_cast <double> (sum_non_pos) / non_pos_counter; // negative average calculation
175+
}
176+
else avg_non_pos = 0.0;
177+
178+
cout << "The number of positive integers entered is: " << pos_counter << endl;
179+
cout << "The number of non-positive integers entered is: " << non_pos_counter << endl << endl;
180+
181+
cout << "The sum of all positive integers is: " << sum_positive << endl; // Part A
182+
cout << "The average of all positive integers is: " << avg_positive << endl << endl; // Part B
183+
184+
cout << "The sum of all non-positive integers is: " << sum_non_pos << endl; // Part C
185+
cout << "The average of all non-positive numbers is: " << avg_non_pos << endl << endl; // Part D
186+
187+
cout << "The sum of all entered integers is: " << sum_all_nums << endl; // Part E
188+
cout << "The average of all entered integers is: " << avg_all_nums << endl << endl; // Part F
189+
190+
cout << "Would you like to perform another calculation?\n"
191+
<< "Enter Y to continue, or any other key to quit: ";
192+
cin >> exit_status;
193+
194+
cout << endl;
195+
196+
} while (exit_status == 'Y' || exit_status == 'y'); // Loop condition to perform add'l calculations
197+
198+
cout << "See you next time!!" << endl << endl;
199+
200+
}
201+
202+
void Q2()
203+
{
204+
205+
char exit_status; // variable to continue or terminate loop
206+
207+
do {
208+
209+
int entry_counter = 0; // Counts how many inputs user has entered.
210+
int pos_counter = 0; // counters to keep track of the # of positive and non-positive integers.
211+
int non_pos_counter = 0; // We assume Zero is not a Positive Integer as in Discrete Math set theory.
212+
int sum_positive = 0; // sum variables for sum calculations.
213+
int sum_non_pos = 0;
214+
int sum_all_nums = 0;
215+
double avg_positive = 0; // average variables for average calculations.
216+
double avg_non_pos = 0;
217+
double avg_all_nums = 0;
218+
int input_number;
219+
220+
cout << "\t=> Sum and Average Calculator <=" << endl << endl;
221+
222+
cout << "Please enter 10 integers, each followed by Enter: " << endl;
223+
224+
while (entry_counter < 10)
225+
{
226+
cin >> input_number;
227+
entry_counter++;
228+
229+
if (input_number > 0)
230+
{
231+
sum_positive = sum_positive + input_number;
232+
pos_counter++;
233+
}
234+
else
235+
{
236+
sum_non_pos = sum_non_pos + input_number;
237+
non_pos_counter++;
238+
}
239+
}
240+
241+
sum_all_nums = sum_positive + sum_non_pos; // sum of all numbers calculation
242+
avg_all_nums = (sum_positive + sum_non_pos) / 10.0; // average of all numbers calculation
243+
244+
if (pos_counter > 0) // run-time error prevention
245+
{
246+
avg_positive = static_cast <double> (sum_positive) / pos_counter; // positive average calculation
247+
}
248+
else avg_positive = 0.0;
249+
250+
if (non_pos_counter > 0) // run-time error prevention
251+
{
252+
avg_non_pos = static_cast <double> (sum_non_pos) / non_pos_counter; // negative average calculation
253+
}
254+
else avg_non_pos = 0.0;
255+
256+
cout << endl << endl;
257+
258+
cout << "The number of positive integers entered is: " << pos_counter << endl;
259+
cout << "The number of non-positive integers entered is: " << non_pos_counter << endl << endl;
260+
261+
cout << "The sum of all positive integers is: " << sum_positive << endl; // Part A
262+
cout << "The average of all positive integers is: " << avg_positive << endl << endl; // Part B
263+
264+
cout << "The sum of all non-positive integers is: " << sum_non_pos << endl; // Part C
265+
cout << "The average of all non-positive numbers is: " << avg_non_pos << endl << endl; // Part D
266+
267+
cout << "The sum of all entered integers is: " << sum_all_nums << endl; // Part E
268+
cout << "The average of all entered integers is: " << avg_all_nums << endl << endl; // Part F
269+
270+
cout << "Would you like to perform another calculation?\n"
271+
<< "Enter Y to continue, or any other key to quit: ";
272+
273+
cin >> exit_status;
274+
275+
} while (exit_status == 'Y' || exit_status == 'y');
276+
277+
cout << endl << endl;
278+
cout << "See you next time!!" << endl << endl;
279+
}

0 commit comments

Comments
 (0)