Archived
1
0
Fork 0

🍻 Add excercise files

This commit is contained in:
Simon V. Lejel 2024-02-06 18:06:16 +01:00
parent f90ca8d2ce
commit f4330e53e0
Signed by: sl
GPG key ID: 6544A0430A2CFFAD
6 changed files with 112 additions and 0 deletions

19
src/excercises/buckets.cc Normal file
View file

@ -0,0 +1,19 @@
# include <iostream>
using namespace std;
int main() {
int a = 1;
int b = 2;
int c = a;
a = b;
b = c;
cout << "A: " << a;
cout << "B: " << b;
return 0;
}

View file

@ -0,0 +1,36 @@
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
char op;
float num1, num2;
cout << "Enter operator: +, -, *, /: ";
cin >> op;
cout << "Enter two operands: ";
cin >> num1 >> num2;
switch (op) {
case '+':
cout << num1 << " + " << num2 << " = " << num1 + num2;
break;
case '-':
cout << num1 << " - " << num2 << " = " << num1 - num2;
break;
case '*':
cout << num1 << " * " << num2 << " = " << num1 * num2;
break;
case '/':
cout << num1 << " / " << num2 << " = " << num1 / num2;
break;
default:
cout << "Operator '" << op << "' is not valid";
break;
}
return 0;
}

View file

@ -0,0 +1,11 @@
# include <iostream>
using namespace std;
int main() {
const double pi = 3.14;
cout << pi;
return 0;
}

View file

@ -0,0 +1,8 @@
// Your first program
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "Hello World!";
return 0;
}

View file

@ -0,0 +1,14 @@
# include <iostream>
using namespace std;
int main() {
double x = 10;
double y = 5;
double z = (x + 10) / (3 * y);
cout << z;
return 0;
}

View file

@ -0,0 +1,24 @@
#include <iostream>
#include <ostream>
using namespace std;
int main() {
double sale = 95000;
cout << "Sale: $" << sale << endl;
const double stateTaxRate = .04;
double stateTax = sale * stateTaxRate;
cout << "State tax: $" << stateTax << endl;
const double countyTaxRate = .02;
double countyTax = sale * countyTax;
cout << "County tax: $" << countyTax << endl;
double totalTax = stateTax + countyTax;
cout << "Total tax: $" << totalTax;
return 0;
}