-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgnm opus cal test github.cpp
133 lines (110 loc) · 5.04 KB
/
mgnm opus cal test github.cpp
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
#include<iostream>
#include<chrono>
#include<thread>
#include<stdlib.h>
using namespace std;
void calfunct() {
// declaring all variables
int cal_opertr;
int cal_num1;
int cal_num2;
int cal_s_d_p_q_a;
string stall;
calstart:
cout << "\n\t\t\t\t\tChoose an operator";
cout << "\n1) Addition";
cout << "\n2) Subtraction";
cout << "\n3) Division";
cout << "\n4) Multiplication";
cout << "\n5) Averages";
cout << "\n6) Back";
cout << "\n\tEnter your choice: ";
cin >> cal_opertr;
switch (cal_opertr) {
case 1:
cout << "\033[2J\033[0;0H";
cout << "\nInput the first number: ";
cin >> cal_num1;
cout << "\033[2J\033[0;0H";
cout << "Input the second number: ";
cin >> cal_num2;
cout << "\033[2J\033[0;0H";
cal_s_d_p_q_a = cal_num1 + cal_num2;
cout << "\033[2J\033[0;0H";
cout <<"\n——————————————————————————";
cout << "\nThe sum was: " << cal_s_d_p_q_a;
cout <<"\n——————————————————————————";
goto calstart;
case 2:
cout << "\033[2J\033[0;0H";
cout << "\nInput the first number: ";
cin >> cal_num1;
cout << "\033[2J\033[0;0H";
cout << "Input the second number: ";
cin >> cal_num2;
cout << "\033[2J\033[0;0H";
cal_s_d_p_q_a = cal_num1 - cal_num2;
cout << "\033[2J\033[0;0H";
cout <<"\n——————————————————————————";
cout << "\nThe difference was: " << cal_s_d_p_q_a;
cout <<"\n——————————————————————————";
goto calstart;
case 3:
cout << "\033[2J\033[0;0H";
cout << "\nInput the first number: ";
cin >> cal_num1;
cout << "\033[2J\033[0;0H";
cout << "Input the second number: ";
cin >> cal_num2;
cout << "\033[2J\033[0;0H";
cal_s_d_p_q_a = cal_num1 / cal_num2;
cout << "\033[2J\033[0;0H";
cout <<"\n——————————————————————————";
cout << "\nThe quotient was: " << cal_s_d_p_q_a;
cout <<"\n——————————————————————————";
goto calstart;
case 4:
cout << "\033[2J\033[0;0H";
cout << "\nInput the first number: ";
cin >> cal_num1;
cout << "\033[2J\033[0;0H";
cout << "Input the second number: ";
cin >> cal_num2;
cout << "\033[2J\033[0;0H";
cal_s_d_p_q_a = cal_num1 * cal_num2;
cout << "\033[2J\033[0;0H";
cout <<"\n——————————————————————————";
cout << "\nThe product was: " << cal_s_d_p_q_a;
cout <<"\n——————————————————————————";
goto calstart;
case 5:
//i honestly dont know how this works but ill try to break it down beacuse i used a little somthing that all programers do called "steal from stack overflow(aka coding reddit for those that dont know)"
cout << "\033[2J\033[0;0H";//same command that clears terminal
int mean_amnt, i; //calling the variables btw i hate how the stackoverflow pepole just call it "clean code" by making their variables one letter to confuse pepole reading it
float num[100], sum=0.0, average;
cout << "Enter the amount of numbers in your data: ";
cin >> mean_amnt;
while (mean_amnt > 200 || mean_amnt <= 0) //ohhhh i get it the'i' variable is how many numbers you have to input
{
cout << "Error; number should be in range of (1 to 200)." << endl;
cout << "Enter the number again: ";
cin >> mean_amnt;
}
for(i = 0; i < mean_amnt; ++i) //this essentially makes it so that it asks you to enter the next number for however many times you said there were numbers
{
cout << i + 1 << ". enter number: ";
cin >> num[i]; // this part is just taking the inputs then adding them to the sum
sum += num[i];
}
average = sum / mean_amnt; // this part is doing what you would be doing by dividing the sum by the amount of numbers you input
cout << "\033[2J\033[0;0H";
cout <<"\n——————————————————————————";
cout << "\nThe average = " << average;
cout <<"\n——————————————————————————";
goto calstart;
}
}
int main() {
calfunct();
return 0;
}