-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment3.cpp
More file actions
237 lines (194 loc) · 4.83 KB
/
assignment3.cpp
File metadata and controls
237 lines (194 loc) · 4.83 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
Project: Assignment 3
Class: CPSC 240
Professor: Dr. Ray Ahmadnia
Authors: Cuevas, Fernando
Huang, Justin
Due: 9/14/2017
*/
#include "stdafx.h" //take out after done with project, only need it cus my visual studio neeeds it.
#include <iostream>
#include <string>
// variables and funtions for question 1
int totalPrice;
int amtDrink, amtFood;
int sodaPrice = 2, waterPrice = 1;
int sub10inchPrice = 3, sub12inchPrice = 5;
int userChoiceSub;
char userChoiceDrink;
void display711Menu();
void get711Order();
void reciptFor711();
//variables and functions for question 2
int averageScore, scores, scoreCount;
int stopLoop = -1;
void getScore();
//variables for question 3
//variables for question 4
short int a, b, c, d, e, f;
short int X, Y;
void displayXYMenu();
void printXYresults();
int main() {
//-----------------------------------QUESTION 1--------------------------------------------------------
//__asm {
//entry:
// call display711Menu; display the menu to console
// call get711Order;
// whatDrinkType:
// mov eax, amtDrink; move the total drinks to eax
// mov bl, 'S'; move S into al, this is to not have another variable to compare
// cmp userChoiceDrink, bl; compare what the user entered
// jne choiceWater; if the user entered S then keep going though else go to choiceWater
//
// choiceSoda : //go here is user chooses soda
// imul sodaPrice;
// mov totalPrice, eax;
// jmp whatSubSize;
//
// choiceWater: // else choose water
// imul waterPrice;
// mov totalPrice, eax;
//
// whatSubSize: //next part will handle what sub size
// mov eax, amtFood;
// mov ebx, 10;
// cmp userChoiceSub, ebx;
// jne subChoice12;
//
// subChoice10:
// imul sub10inchPrice;
// add totalPrice, eax;
// jmp displayRecipte;
//
// subChoice12:
// imul sub12inchPrice;
// add totalPrice, eax;
//
// displayRecipte:
// call reciptFor711;
//
//}
//-----------------------------------QUESTION 2--------------------------------------------------------
/*todo*/
//-----------------------------------QUESTION 3--------------------------------------------------------
/*todo*/
//-----------------------------------QUESTION 4--------------------------------------------------------
/*
_asm {
call displayXYMenu;
getY:
// find a*f - c * d
mov ax, a;
imul f;
mov bx, ax;
mov ax, c;
imul d;
sub bx, ax;
mov cx, bx;
// find a*e - b * d
mov ax, a; move a in ax multiply by e
imul e;
mov bx, ax; move ax into bx for stroage
mov ax, b; move b in ax and multiply with d
imul d;
sub bx, ax; subtract bx with ax
mov ax, cx; move result into cx, which is the numerator
// divide numerator with denominato
cwd; convert to double word and then divid
idiv bx;
mov Y, ax;
getX:
//find c*e - b*f
mov ax, c;
imul e;
mov bx, ax;
mov ax, b;
imul f;
sub bx, ax;
mov cx, bx;
//find a*e - b*d
mov ax, a;
imul e;
mov bx, ax;
mov ax, b;
imul d;
sub bx, ax;
mov ax, cx;
//divide
cwd;
idiv bx;
mov X, ax;
display:
call printXYresults;
}
*/
return 0;
}
// functions for question 1
void display711Menu() {
std::cout << "-----------------------------7-11 Convienient Store------------------------------\n";
std::cout << " Drinks\n\tSoda(S)...................................$2\n";
std::cout << "\tWater(W).....................................$1\n";
std::cout << " Sandwiches\n\t10 inches.............................$3\n";
std::cout << "\t12 inches......................................$5\n\n";
}
void get711Order() {
std::cout << " How many drinks? ";
std::cin >> amtDrink;
std::cout << "\tWhat kind of drink?(S=Soda, W=Water) ";
std::cin >> userChoiceDrink;
std::cout << "\n How many sandwiches? ";
std::cin >> amtFood;
std::cout << "\tWhat size of sandwich(10/12 inches)? ";
std::cin >> userChoiceSub;
}
void reciptFor711() {
std::cout << " Your total bill = " << totalPrice << std::endl;
}
//function for question 4
void displayXYMenu() {
std::cout << "This program solves the system\n\taX + bY = c\n\tdX + eY = f\n";
std::cout << "Enter the values of a, b and c: ";
std::cin >> a >> b >> c;
std::cout << "Enter the values of d, e and f: ";
std::cin >> d >> e >> f;
}
void printXYresults() {
std::cout << "\tX = " << X << "\n\tY = " << Y << std::endl;
}
/*almost done part 3
#include <iostream>
char c;
int lCount, uCount;
void getNextChar(){
std::cin.get(c);
}
void displayCount(){
std::cout << "Total Lower == " << lCount << "\nTotal Upper == " << uCount << std::endl;
}
int main(){
std::cout << "Enter a sentence: ";
_asm{
whileLoop:
call getNextChar
cmp c, '\n'
je done
cmp c, 'A'
jle whileLoop
jge isUpper
isUpper:
cmp c,'Z'
jge possibleLower
inc uCount
jmp whileLoop
possibleLower:
cmp c, 'a'
jle whileLoop
cmp c, 'z'
jle
done:
call displayCount
}
}
*/