get the old files from sololearn
This commit is contained in:
commit
f46edc2621
5 changed files with 316 additions and 0 deletions
56
files/KOS.cpp
Normal file
56
files/KOS.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
//Alpha Kaiser Operating System or KOS 0.2
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
65
files/KOSFunctions.h
Normal file
65
files/KOSFunctions.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
// KOS functions
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#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
|
||||
|
14
files/KOSVariables.h
Normal file
14
files/KOSVariables.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include "calculator.h"
|
||||
#include "KOSFunctions.h"
|
||||
#ifndef KOSVariables_h
|
||||
#define KOSVariables_h
|
||||
using namespace std;
|
||||
|
||||
string input;
|
||||
|
||||
|
||||
|
||||
#endif
|
9
files/calculator.cxx
Normal file
9
files/calculator.cxx
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <iostream>
|
||||
#include "calculator.h"
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
calculator();
|
||||
return 0;
|
||||
}
|
172
files/calculator.h
Normal file
172
files/calculator.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
#include <iostream>
|
||||
#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
|
||||
|
Loading…
Add table
Reference in a new issue