commit f46edc2621e95bebddc8f32de9b0110e91ea77bd Author: Christoph J. Scherr Date: Wed Mar 12 13:10:55 2025 +0100 get the old files from sololearn diff --git a/files/KOS.cpp b/files/KOS.cpp new file mode 100644 index 0000000..31b41f5 --- /dev/null +++ b/files/KOS.cpp @@ -0,0 +1,56 @@ +//Alpha Kaiser Operating System or KOS 0.2 +#include +#include +#include +#include "calculator.h" +#include "KOSFunctions.h" +using namespace std; + +/*TODO: add back command to all menus, add saveble notes, add support for commands whit big or small letters, fix rand with 0, fix rand crash by using not integers */ +//DATE: 27.11.2019 [DD.MM:YYYY] + +int main() +{ + printString("starting..."); + printString("Started Successfully"); + printString("Type help for a list of commands."); + + bool shutdown = false; + + do + { + printStringInstruction("[MAIN]waiting for input..."); + cin >> input; + if (input == "shutdown") + { + printString("Shutting down..."); + shutdown = true; + } + if (input == "help") + { + helpCommand(); + } + if (input == "calculator") + { + calculator(); + } + + if (input == "rand") + { + printStringInstruction("biggest possible number? 0 if it doesn't matter. Point numbers are currently not supported."); + + //backToMain(); + + double inputrand; + cin >> inputrand; + int max = 1 + inputrand; + srand(time(0)); + cout << endl + << 0 + (rand() % max) << endl; + } + } while (shutdown == false); + + return 0; +} + + diff --git a/files/KOSFunctions.h b/files/KOSFunctions.h new file mode 100644 index 0000000..dbe4429 --- /dev/null +++ b/files/KOSFunctions.h @@ -0,0 +1,65 @@ +// KOS functions +#include +#include +#include +#ifndef kosfunctions_h +#define kosfunctions_h +using namespace std; + +string input; + +int TSRandomInt(bool useCustomSeed = false, int customSeed = 1, int maxValue = 0) +{ + srand(time(0)); + if (useCustomSeed == true) + { + srand(customSeed); + } + + int modulusvar; + + if (maxValue != 0) + { + modulusvar = 1 + maxValue; + } + return (rand() % (modulusvar)); +} + +void printString(string printString1) +{ + cout << endl + << printString1 << endl; +} + +void printStringInstruction(string printString1) +{ + cout << endl + << printString1 << endl + << endl; +} + +void helpCommand() +{ + if (input == "help") + ; + { + cout << endl + << "help - lets the user see this menu." << endl + << "shutdown - shut's down the software." << endl + << "calculator - opens the calculator menu." << endl + << "rand - generates a random number." << endl; + } +} + +void backToMain() +{ + /* if(input == "back" || input == "Back") + { + cout << "entering main menu..." << endl << endl; + + } +*/ +} + +#endif + diff --git a/files/KOSVariables.h b/files/KOSVariables.h new file mode 100644 index 0000000..484d6b2 --- /dev/null +++ b/files/KOSVariables.h @@ -0,0 +1,14 @@ +#include +#include +#include +#include "calculator.h" +#include "KOSFunctions.h" +#ifndef KOSVariables_h +#define KOSVariables_h +using namespace std; + +string input; + + + +#endif diff --git a/files/calculator.cxx b/files/calculator.cxx new file mode 100644 index 0000000..67c49d7 --- /dev/null +++ b/files/calculator.cxx @@ -0,0 +1,9 @@ +#include +#include "calculator.h" +using namespace std; + +int main() +{ + calculator(); + return 0; +} diff --git a/files/calculator.h b/files/calculator.h new file mode 100644 index 0000000..ced877a --- /dev/null +++ b/files/calculator.h @@ -0,0 +1,172 @@ +#include +#ifndef calculator_h +#define calculator_h +using namespace std; + +void Addition() +{ + cout << endl << "Please enter variable a." << endl << endl; + float num1; + cin >> num1; + cout << endl << "Please enter variable b." << endl << endl; + float num2; + cin >> num2; + float sumPlus = num1 + num2; + cout << endl << num1 << "+" << num2 << "=" << sumPlus << endl; +} + +// for addition + + +void Subtraction() +{ + cout << endl << "Please enter variable a." << endl << endl; + float num1; + cin >> num1; + cout << endl << "Please enter variable b." << endl << endl; + float num2; + cin >> num2; + float sumMin = num1 - num2; + cout << endl << num1 << "-" << num2 << "=" << sumMin << endl; +} + +// for subtraction - + +void Multiply() +{ + cout << endl << "Please enter variable a." << endl << endl; + float num1; + cin >> num1; + cout << endl << "Please enter variable b." << endl << endl; + float num2; + cin >> num2; + float sumMulti = num1 * num2; + cout << endl << num1 << "*" << num2 << "=" << sumMulti << endl; +} + +// for multiplication * + +void Divide() +{ + cout << endl << "Please enter variable a." << endl << endl; + float num1; + cin >> num1; + cout << endl << "Please enter variable b." << endl << endl; + float num2; + cin >> num2; + float sumDiv = num1 / num2; + cout << endl << num1 << ":" << num2 << "=" << sumDiv << endl; +} + +// for dividation / + +void Modulus() +{ + cout << endl << "Please enter variable a." << endl << endl; + int num1; + cin >> num1; + cout << endl<< "Please enter variable b." << endl << endl; + int num2; + cin >> num2; + int sumMod = num1 % num2; + cout << endl << num1 << "%" << num2 << "=" << sumMod << endl; +} + +// for Modulis operator % + +int calculator() + +{ + while (true) + { + cout << endl << "Please enter what you want to calculate." << endl + << endl + << "Quit / Q --> stop" << endl + << "+ / 1 --> +" << endl + << "- / 2 --> -" << endl + << "* / 3 --> *" << endl + << ": / 4 --> /" << endl + << "% / 5 --> %" << endl + << endl; + + // sends input table to user + + { + char input; + cin >> input; + + // user input for operations + + switch (input) + { + case 'q': + cout << endl << "stopping calculator" << endl; + return 0; + + case 'Q': + cout << endl << "stopping calculator" << endl; + return 0; + + case 'quit': + cout << endl << "stopping calculator" << endl; + return 0; + + case 'Quit': + cout << endl << "stopping calculator" << endl; + return 0; + + case '+': + Addition(); + break; + + case '1': + Addition(); + break; + + case '-': + Subtraction(); + break; + + case '2': + Subtraction(); + break; + + case '*': + Multiply(); + break; + + case '3': + Multiply(); + break; + + case '/': + Divide(); + break; + + case '4': + Divide(); + break; + + case ':': + Divide(); + break; + + case '%': + Modulus(); + break; + + case '5': + Modulus(); + break; + + // for integrating operators to calculator + + default: + cout << "You can't caltulate with that, can you?" << endl + << endl; + } + } + } +} +// for illigal input +#endif +