aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab2/CST116F2021-Lab2.cpp
blob: 639232d1ef3eda1b448de590f348888172c71a49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//Code by Jordan Harris-Toovy for OIT'S CST116-01P Lab 2 - October 2021
//Un-comment blocks for each assignment (re-comment when finished)

#include <iostream>
#include <iomanip>

//PART 3c - 4.13#2:
/*
using std::cout;

int main()
{
	char ascii = 67;
	cout << ascii << '\n';
	ascii = 43;
	cout << ascii << '\n';
	cout << ascii << '\n';

	return 0;
}
*/

//PART 3c - 4.13#3:
/*
using std::cout;

int main()
{
	int myAgeYears = 24;
	int myAgeDays;
	const int yearDays = 365;

	myAgeDays = myAgeYears * yearDays;

	cout << "I am " << myAgeDays << " Days old.";

	return 0;
}
*/

//PART 4a - 5.4#1:
/*
using std::cout;
using std::cin;

int main()
{
	float body_temp;
	cout << "Enter you body temperature: ";
	cin >> body_temp;

	cout.setf(std::ios::fixed);
	cout.width(6);
	cout << std::setprecision(1) << body_temp;

	return 0;
}
*/

//PART 4a - 5.4#2:
/*
using std::cout;
using std::cin;
using std::setw;
using std::endl;

int main()
{
	const int padding1 = 15;
	const int padding2 = 30;

	cout.setf(std::ios::fixed);
	cout.setf(std::ios::left);


	cout << setw(padding1) << "First Name" << setw(padding1 - 5) << "GPA" << setw(padding1) << "Class" << setw(padding2)
		 << "Major" << setw(padding1) << "Credits" << endl;

	cout << setw(padding1) << "Bob" << setw(padding1 - 5) << std::setprecision(2) << 3.23 << setw(padding1) << "Freshman" << setw(padding2)
		 << "Software Engineering" << setw(padding1) << std::setprecision(0) << 23 << endl;

	cout << setw(padding1) << "Jamie" << setw(padding1 - 5) << std::setprecision(2) << 0.98 << setw(padding1) << "Freshman" << setw(padding2)
		 << "Underwater Basket" << setw(padding1) << std::setprecision(0) << 15 << endl;

	cout << setw(padding1) << "Marcus" << setw(padding1 - 5) << std::setprecision(2) << 4.00 << setw(padding1) << "Freshman" << setw(padding2)
		 << "Management" << setw(padding1) << std::setprecision(0) << 3 << endl;

	cout << setw(padding1) << "Phong" << setw(padding1 - 5) << std::setprecision(2) << 3.75 << setw(padding1) << "Junior" << setw(padding2)
		 << "Encryption" << setw(padding1) << std::setprecision(0) <<101 << endl;

	cout << setw(padding1) << "Webster" << setw(padding1 - 5) << std::setprecision(2) << 2.00 << setw(padding1) << "Sophomore" << setw(padding2)
		 << "Wildlife Management" << setw(padding1) << std::setprecision(0) << 56 << endl;

	return 0;
}

*/

//PART 4b - 5.9:
/*
//Modified code from Chapter 5 Debug.cpp

using std::cout;
using std::cin;
using std::endl;

int main()
{
	float money = 123.45F;
	float raise = 100.00F; //Set to 100 to avoid unexpected behavior

	cout << "You have $";
	cout << money << endl;

	// Breakpoint 1
	// Put a breakpoint on the following line (done)
	cout << "Enter percent raise: ";
	cin >> raise;

	money = money * (1.00F + (raise / 100.00F)); //Divide by 100 and add result to 1 to make it percent raise

	cout << "After your raise you have $";
	cout << money << endl;

	return 0;
}
*/

//PART 4b - 5.10:
/*
//Modified code from PE 5_1.cpp 
//Fixed header spelling
using std::cout;
using std::cin;

int main()
{
	double  ProductionHours,
		PreProductionHours,
		ProducersHours,
		ProductionCost,
		PreProductionCost,
		ProducersCost,
		TotalCost;
	//Fixed tabbing

	const double PRODUCTION_RATE = 1.10F,
		PRE_PRODUCTION_RATE = 0.90F,
		PRODUCERS_RATE = 1.35F;
	//Added arbitrary process constants (not specified in the book)

	cout << "Enter Production Hours: ";
	cin >> ProductionHours;
	cout << "\nEnter Pre-Production Hours: ";
	cin >> PreProductionHours;
	cout << "\nEnter Producers Hours: ";
	cin >> ProducersHours;

	ProductionCost = ProductionHours * PRODUCTION_RATE;
	PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE;
	ProducersCost = ProducersHours * PRODUCERS_RATE;
	//Fixed missing vars - see [Added arbitrary process constants]

	TotalCost = ProductionCost + PreProductionCost + ProducersCost;
	//Fixed inconsistent capitalization

	cout << "\n\t\tCar Dealership Bill\n";
	cout << "\n\nProduction Cost: ";
	cout << ProductionCost;

	cout << "\n\nPre-Production Cost: ";
	cout << PreProductionCost;

	cout << "\n\nProducers Cost: ";
	cout << ProducersCost;

	cout << "\n\nWeekly Total Cost: ";
	cout << TotalCost << std::endl;
	//Fixed syntax

	return 0;
}
*/