mikeyworx

DATALGO SPACE

Jun 27th, 2023
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.69 KB | None | 0 0
  1. DATASPACE.cpp
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. // Function prototypes
  9. void activityOne();
  10. void activityTwo();
  11. void activityThree();
  12. void activityFour();
  13. void activityFive();
  14. void rectangle();
  15. void square();
  16. void triangle();
  17. void circle();
  18. float additionFunction(float, float);
  19. float subtractionFunction(float, float);
  20. float multiplicationFunction(float, float);
  21. float divisionFunction(float, float);
  22.  
  23. // Global variables
  24. double length, width, side, base, height, radius, pi = 3.141592653589793238462643383279502884197;
  25. char option;
  26.  
  27. int main()
  28. {
  29.     char opt;
  30.  
  31.     cout << "\t\t  DAATALGO SPACE" << endl;
  32.     cout << "\n============Welcome to my AIO activity============";
  33.     cout << "\n ====Made & Compiled by John Michael Gonzales==== ";
  34.     cout << "\n====================BSIT CUBAO2===================" << endl;
  35.     do {
  36.         cout << "\nPlease choose desired choices below:\n"
  37.             << "[A] Activity #1\n"
  38.             << "[B] Activity #2\n"
  39.             << "[C] Activity #3\n"
  40.             << "[D] Activity #4\n"
  41.             << "[E] Activity #5\n"
  42.             << "[F] Exit\n\n"
  43.             << "Enter your choice: ";
  44.         cin >> opt;
  45.  
  46.         switch (opt) {
  47.         case 'A':
  48.         case 'a':
  49.             activityOne();
  50.             break;
  51.         case 'B':
  52.         case 'b':
  53.             activityTwo();
  54.             break;
  55.         case 'C':
  56.         case 'c':
  57.             activityThree();
  58.             break;
  59.         case 'D':
  60.         case 'd':
  61.             activityFour();
  62.             break;
  63.         case 'E':
  64.         case 'e':
  65.             activityFive();
  66.             break;
  67.         case 'F':
  68.         case 'f':
  69.             cout << "\nThank you for using me! <3" << endl;
  70.             break;
  71.         default:
  72.             cout << "Invalid input. Please try again!" << endl;
  73.             break;
  74.         }
  75.     } while (opt != 'F' && opt != 'f');
  76.  
  77.     return 0;
  78. }
  79.  
  80. void activityOne()
  81. {
  82.     string name;
  83.     double num1, num2;
  84.  
  85.     cout << "\n============Welcome to Activity #1============\n" << endl;
  86.  
  87.     cout << "Enter your Name: ";
  88.     cin >> name;
  89.     cout << "Enter 1st number: ";
  90.     cin >> num1;
  91.     cout << "Enter 2nd number: ";
  92.     cin >> num2;
  93.  
  94.     cout << "\n=======Welcome to " << name << "'s Program=======\n";
  95.  
  96.     double product, quotient, sum, difference;
  97.  
  98.     product = num1 * num2;
  99.     quotient = num1 / num2;
  100.     sum = num1 + num2;
  101.     difference = num1 - num2;
  102.  
  103.     cout << "The Product of two numbers is   : " << product << endl;
  104.     cout << "The Quotient of two numbers is  : " << quotient << endl;
  105.     cout << "The Sum of two numbers is       : " << sum << endl;
  106.     cout << "The Difference of two numbers is: " << difference << endl;
  107.  
  108.     char option;
  109.     while (true) {
  110.         cout << "\nSelect an option:\n"
  111.             << "[M] Main Menu\n"
  112.             << "[T] Try Again\n"
  113.             << "[E] Exit\n"
  114.             << "Enter your choice: ";
  115.         cin >> option;
  116.  
  117.         switch (option) {
  118.         case 'M':
  119.         case 'm':
  120.             return;
  121.         case 'T':
  122.         case 't':
  123.             activityOne();
  124.             return;
  125.         case 'E':
  126.         case 'e':
  127.             exit(1);
  128.         default:
  129.             cout << "Invalid option. Please try again!" << endl;
  130.             break;
  131.         }
  132.     }
  133. }
  134.  
  135. void activityTwo() {
  136.  
  137.     double totalGross, philHealth, sss, tax, pagIbig, deduction, salary;
  138.     int hourlyRate, hoursOfWork, daysOfWork, absences, tardiness;
  139.     char option;
  140.     cout << "\n============Welcome to Activity #2============\n" << endl;
  141.     cout << "-- Payroll System -- Daily Rate --\n\nEnter Hourly Rate           : ";
  142.     cin >> hourlyRate;
  143.     cout << "Enter Hours of Work         : ";
  144.     cin >> hoursOfWork;
  145.     cout << "Enter Days of Work          : ";
  146.     cin >> daysOfWork;
  147.     cout << "Enter Absences              : ";
  148.     cin >> absences;
  149.     cout << "Enter Tardiness or 0 if none: ";
  150.     cin >> tardiness;
  151.  
  152.     totalGross = hourlyRate * hoursOfWork * daysOfWork;
  153.     cout << "\nTOTAL GROSS: " << totalGross << endl;
  154.  
  155.     cout << "\nDeductions\n---------------\nPhilHealth: ";
  156.     cin >> philHealth;
  157.     cout << "SSS       : ";
  158.     cin >> sss;
  159.     cout << "Tax       : ";
  160.     cin >> tax;
  161.     cout << "Pagibig   : ";
  162.     cin >> pagIbig;
  163.     cout << "Absences  : " << absences << endl;
  164.     cout << "Tardiness : " << tardiness << endl;
  165.     cout << "---------------" << endl;
  166.  
  167.     absences = absences * 8 * hourlyRate;
  168.     tardiness = tardiness * 50;
  169.     deduction = philHealth + sss + tax + pagIbig + absences + tardiness;
  170.     cout << "Total Deduction: " << deduction << endl;
  171.     salary = totalGross - deduction;
  172.     cout << "\nTOTAL SALARY : " << salary << endl;
  173.  
  174. yesOrNo:
  175.     cout << "\nGo back to Main Menu? [Y/N]: ";
  176.     cin >> option;
  177.     if (option == 'y' || option == 'Y') {
  178.  
  179.         cout << "\n\n";
  180.         main();
  181.  
  182.     }
  183.     else if (option == 'n' || option == 'N') {
  184.         exit(1);
  185.     }
  186.     else {
  187.         cout << "INVALID INPUT!" << endl;
  188.         goto yesOrNo;
  189.     }
  190. }
  191.  
  192.  
  193.  
  194. using namespace std;
  195.  
  196. void activityThree()
  197. {
  198.     cout << "\n============Welcome to Activity #3============\n" << endl;
  199.  
  200.     string itemName;
  201.     double price, total = 0, grandTotal = 0, discountAmount = 0;
  202.     int quantity;
  203.     char addMore, withDiscount;
  204.     const double DISCOUNT_PERCENTAGE = 0.1;
  205.  
  206.     cout << "---------------------------" << endl;
  207.     cout << "       CASH REGISTER       " << endl;
  208.     cout << "---------------------------" << endl;
  209.  
  210.     do {
  211.         cout << "Enter item name: ";
  212.         cin.ignore(); // Ignore the newline character left by previous cin
  213.         getline(cin, itemName);
  214.         cout << "Enter price: ₱";
  215.         cin >> price;
  216.         cout << "Enter quantity: ";
  217.         cin >> quantity;
  218.  
  219.         double itemTotal = price * quantity;
  220.         total += itemTotal;
  221.         grandTotal = total;
  222.  
  223.         cout << "Apply discount? (Y/N): ";
  224.         cin >> withDiscount;
  225.         if (withDiscount == 'Y' || withDiscount == 'y') {
  226.             discountAmount = total * DISCOUNT_PERCENTAGE;
  227.             grandTotal = total - discountAmount;
  228.         }
  229.  
  230.         cout << setprecision(2) << fixed;
  231.         cout << "---------------------------" << endl;
  232.         cout << "Item: " << itemName << endl;
  233.         cout << "Price: ₱" << price << endl;
  234.         cout << "Quantity: " << quantity << endl;
  235.         cout << "Total: ₱" << itemTotal << endl;
  236.         cout << "---------------------------" << endl;
  237.         cout << "Total: ₱" << total << endl;
  238.  
  239.         cout << "Add another item? (Y/N): ";
  240.         cin >> addMore;
  241.         cin.ignore(); // Ignore the newline character left by cin
  242.  
  243.     } while (addMore == 'Y' || addMore == 'y');
  244.  
  245.     cout << "---------------------------" << endl;
  246.     cout << "Grand Total: ₱" << grandTotal << endl;
  247.     cout << "Discount: ₱" << discountAmount << endl;
  248.     cout << "---------------------------" << endl;
  249.  
  250.     char option;
  251. optionSelection:
  252.     cout << "\nSelect an option:\n"
  253.         << "[M] Main Menu\n"
  254.         << "[T] Try Again\n"
  255.         << "[E] Exit\n"
  256.         << "Enter your choice: ";
  257.     cin >> option;
  258.  
  259.     switch (option) {
  260.     case 'M':
  261.     case 'm':
  262.         main();
  263.         break;
  264.     case 'T':
  265.     case 't':
  266.         activityThree();
  267.         break;
  268.     case 'E':
  269.     case 'e':
  270.         cout << "Exiting..." << endl;
  271.         break;
  272.     default:
  273.         cout << "Invalid option. Please try again." << endl;
  274.         goto optionSelection;
  275.     }
  276.  
  277.     cout << "\n============================================\n" << endl;
  278. }
  279.  
  280.  
  281.  
  282. void activityFour() {
  283.  
  284.     cout << "\n============Welcome to Activity #4============\n" << endl;
  285.     cout << "\n==Welcome to Area Computation Program== \nPlease Choose:\n[A] Find the Area of Rectangle\n[B] Find the Area of Square\n[C] Find the Area of Triangle\n[D] Find the Area of Circle\n[E] Exit" << endl;
  286.  
  287. selection:
  288.  
  289.     cout << "Enter Selection: ";
  290.     cin >> option;
  291.  
  292.     if (option == 'a' || option == 'A') {
  293.         rectangle();
  294.     }
  295.     else if (option == 'b' || option == 'B') {
  296.         square();
  297.     }
  298.     else if (option == 'c' || option == 'C') {
  299.         triangle();
  300.     }
  301.     else if (option == 'd' || option == 'D') {
  302.         circle();
  303.     }
  304.     else if (option == 'e' || option == 'E') {
  305.         cout << "\nThank you for using this program! :)" << endl;
  306.         exit(1);
  307.     }
  308.     else {
  309.         cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
  310.         goto selection;
  311.     }
  312. }
  313.  
  314. void rectangle() {
  315.  
  316.     cout << "\n==Welcome to Area of Rectangle==\n\nEnter the Length: ";
  317.     cin >> length;
  318.     cout << "Enter the Width : ";
  319.     cin >> width;
  320.  
  321.     double areaOfRectangle = width * length;
  322.  
  323.     cout << "The Area of the Rectangle is: " << areaOfRectangle << endl;
  324.  
  325. selection:
  326.  
  327.     cout << "Go back to Main Menu? [Y/N] : ";
  328.     cin >> option;
  329.  
  330.     if (option == 'y' || option == 'Y') {
  331.         cout << "\n\n";
  332.         main();
  333.     }
  334.     else if (option == 'n' || option == 'N') {
  335.         cout << "\nThank you for using this program! :)" << endl;
  336.         exit(1);
  337.     }
  338.     else {
  339.         cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
  340.         goto selection;
  341.     }
  342.  
  343.     return;
  344. };
  345.  
  346. void square() {
  347.  
  348.     cout << "\n==Welcome to Area of Square==\n\nEnter the side: ";
  349.     cin >> side;
  350.  
  351.     double areaOfsquare = side * side;
  352.  
  353.     cout << "The Area of the Square is   : " << areaOfsquare << endl;
  354.  
  355. selection:
  356.  
  357.     cout << "Go back to Main Menu? [Y/N] : ";
  358.     cin >> option;
  359.  
  360.     if (option == 'y' || option == 'Y') {
  361.         cout << "\n\n";
  362.         main();
  363.     }
  364.     else if (option == 'n' || option == 'N') {
  365.         cout << "\nThank you for using this program! :)" << endl;
  366.         exit(1);
  367.     }
  368.     else {
  369.         cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
  370.         goto selection;
  371.     }
  372.  
  373.     return;
  374. };
  375.  
  376. void triangle() {
  377.  
  378.     cout << "\n==Welcome to Area of Triangle==\n\nEnter the Base  : ";
  379.     cin >> base;
  380.     cout << "Enter the Height: ";
  381.     cin >> height;
  382.  
  383.     double areaOfTriangle = 0.5 * (base * height);
  384.  
  385.     cout << "The Area of the Triangle is   : " << areaOfTriangle << endl;
  386.  
  387. selection:
  388.  
  389.     cout << "Go back to Main Menu? [Y/N] : ";
  390.     cin >> option;
  391.  
  392.     if (option == 'y' || option == 'Y') {
  393.         cout << "\n\n";
  394.         main();
  395.     }
  396.     else if (option == 'n' || option == 'N') {
  397.         cout << "\nThank you for using this program! :)" << endl;
  398.         exit(1);
  399.     }
  400.     else {
  401.         cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
  402.         goto selection;
  403.     }
  404.  
  405.     return;
  406. };
  407.  
  408. void circle() {
  409.  
  410.     cout << "\n==Welcome to Area of Circle==\n\nEnter the radius  : ";
  411.     cin >> radius;
  412.  
  413.     double areaOfCircle = pi * (radius * radius);
  414.  
  415.     cout << "The Area of the Circle is   : " << areaOfCircle << endl;
  416.  
  417. selection:
  418.  
  419.     cout << "Go back to Main Menu? [Y/N] : ";
  420.     cin >> option;
  421.  
  422.     if (option == 'y' || option == 'Y') {
  423.         cout << "\n\n";
  424.         main();
  425.     }
  426.     else if (option == 'n' || option == 'N') {
  427.         cout << "\nThank you for using this program! :)" << endl;
  428.         exit(1);
  429.     }
  430.     else {
  431.         cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
  432.         goto selection;
  433.     }
  434. }
  435.  
  436. void activityFive() {
  437.  
  438.     float firstNum, secondNum;
  439.     char option;
  440.  
  441.     cout << "\n============Welcome to Activity #5============\n" << endl;
  442.     cout << "===Welcome to Calculator Program===\n[A] Addtion\n[B] Subtraction\n[C] Multiplication\n[D] Division" << endl;
  443.  
  444. yesOrNo:
  445.  
  446.     cout << "Enter your choice (A-D): ";
  447.     cin >> option;
  448.  
  449.     if (option == 'a' || option == 'A') {
  450.  
  451.         cout << "Enter First Number     : ";
  452.         cin >> firstNum;
  453.  
  454.         cout << "Enter Second Number    : ";
  455.         cin >> secondNum;
  456.         cout << "\nResult = " << additionFunction(firstNum, secondNum) << endl;
  457.  
  458.     yesOrNo1:
  459.         cout << "\nGo back to Main Menu? [Y/N]: ";
  460.         cin >> option;
  461.         if (option == 'y' || option == 'Y') {
  462.  
  463.             cout << "\n\n";
  464.             main();
  465.  
  466.         }
  467.         else if (option == 'n' || option == 'N') {
  468.             exit(1);
  469.         }
  470.         else {
  471.             cout << "INVALID INPUT!" << endl;
  472.             goto yesOrNo1;
  473.         }
  474.     }
  475.     else if (option == 'b' || option == 'B') {
  476.  
  477.         cout << "Enter First Number     : ";
  478.         cin >> firstNum;
  479.  
  480.         cout << "Enter Second Number    : ";
  481.         cin >> secondNum;
  482.         cout << "\nResult = " << subtractionFunction(firstNum, secondNum) << endl;
  483.  
  484.     yesOrNo2:
  485.         cout << "\nGo back to Main Menu? [Y/N]: ";
  486.         cin >> option;
  487.         if (option == 'y' || option == 'Y') {
  488.  
  489.             cout << "\n\n";
  490.             main();
  491.  
  492.         }
  493.         else if (option == 'n' || option == 'N') {
  494.             exit(2);
  495.         }
  496.         else {
  497.             cout << "INVALID INPUT!" << endl;
  498.             goto yesOrNo2;
  499.         }
  500.  
  501.     }
  502.     else if (option == 'c' || option == 'C') {
  503.  
  504.         cout << "Enter First Number     : ";
  505.         cin >> firstNum;
  506.  
  507.         cout << "Enter Second Number    : ";
  508.         cin >> secondNum;
  509.         cout << "\nResult = " << multiplicationFunction(firstNum, secondNum) << endl;
  510.  
  511.     yesOrNo3:
  512.         cout << "\nGo back to Main Menu? [Y/N]: ";
  513.         cin >> option;
  514.         if (option == 'y' || option == 'Y') {
  515.  
  516.             cout << "\n\n";
  517.             main();
  518.  
  519.         }
  520.         else if (option == 'n' || option == 'N') {
  521.             exit(3);
  522.         }
  523.         else {
  524.             cout << "INVALID INPUT!" << endl;
  525.             goto yesOrNo3;
  526.         }
  527.  
  528.     }
  529.     else if (option == 'd' || option == 'D') {
  530.  
  531.         cout << "Enter First Number     : ";
  532.         cin >> firstNum;
  533.  
  534.         cout << "Enter Second Number    : ";
  535.         cin >> secondNum;
  536.         cout << "\nResult = " << divisionFunction(firstNum, secondNum) << endl;
  537.  
  538.     yesOrNo4:
  539.         cout << "\nGo back to Main Menu? [Y/N]: ";
  540.         cin >> option;
  541.         if (option == 'y' || option == 'Y') {
  542.  
  543.             cout << "\n\n";
  544.             main();
  545.  
  546.         }
  547.         else if (option == 'n' || option == 'N') {
  548.             exit(4);
  549.         }
  550.         else {
  551.             cout << "INVALID INPUT!" << endl;
  552.             goto yesOrNo4;
  553.         }
  554.  
  555.     }
  556.     else {
  557.  
  558.         cout << "INVALID INPUT PLEASE TRY AGAIN!" << endl;
  559.         goto yesOrNo;
  560.     }
  561. }
  562.  
  563. float additionFunction(float numOne, float numTwo) {
  564.  
  565.     return numOne + numTwo;
  566.  
  567. };
  568.  
  569. float subtractionFunction(float numOne, float numTwo) {
  570.  
  571.     return numOne - numTwo;
  572.  
  573. };
  574.  
  575. float multiplicationFunction(float numOne, float numTwo) {
  576.  
  577.     return numOne * numTwo;
  578.  
  579. };
  580.  
  581. float divisionFunction(float numOne, float numTwo) {
  582.  
  583.     return numOne / numTwo;
  584.  
  585. };
  586.  
Advertisement
Add Comment
Please, Sign In to add comment