Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DATASPACE.cpp
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- // Function prototypes
- void activityOne();
- void activityTwo();
- void activityThree();
- void activityFour();
- void activityFive();
- void rectangle();
- void square();
- void triangle();
- void circle();
- float additionFunction(float, float);
- float subtractionFunction(float, float);
- float multiplicationFunction(float, float);
- float divisionFunction(float, float);
- // Global variables
- double length, width, side, base, height, radius, pi = 3.141592653589793238462643383279502884197;
- char option;
- int main()
- {
- char opt;
- cout << "\t\t DAATALGO SPACE" << endl;
- cout << "\n============Welcome to my AIO activity============";
- cout << "\n ====Made & Compiled by John Michael Gonzales==== ";
- cout << "\n====================BSIT CUBAO2===================" << endl;
- do {
- cout << "\nPlease choose desired choices below:\n"
- << "[A] Activity #1\n"
- << "[B] Activity #2\n"
- << "[C] Activity #3\n"
- << "[D] Activity #4\n"
- << "[E] Activity #5\n"
- << "[F] Exit\n\n"
- << "Enter your choice: ";
- cin >> opt;
- switch (opt) {
- case 'A':
- case 'a':
- activityOne();
- break;
- case 'B':
- case 'b':
- activityTwo();
- break;
- case 'C':
- case 'c':
- activityThree();
- break;
- case 'D':
- case 'd':
- activityFour();
- break;
- case 'E':
- case 'e':
- activityFive();
- break;
- case 'F':
- case 'f':
- cout << "\nThank you for using me! <3" << endl;
- break;
- default:
- cout << "Invalid input. Please try again!" << endl;
- break;
- }
- } while (opt != 'F' && opt != 'f');
- return 0;
- }
- void activityOne()
- {
- string name;
- double num1, num2;
- cout << "\n============Welcome to Activity #1============\n" << endl;
- cout << "Enter your Name: ";
- cin >> name;
- cout << "Enter 1st number: ";
- cin >> num1;
- cout << "Enter 2nd number: ";
- cin >> num2;
- cout << "\n=======Welcome to " << name << "'s Program=======\n";
- double product, quotient, sum, difference;
- product = num1 * num2;
- quotient = num1 / num2;
- sum = num1 + num2;
- difference = num1 - num2;
- cout << "The Product of two numbers is : " << product << endl;
- cout << "The Quotient of two numbers is : " << quotient << endl;
- cout << "The Sum of two numbers is : " << sum << endl;
- cout << "The Difference of two numbers is: " << difference << endl;
- char option;
- while (true) {
- cout << "\nSelect an option:\n"
- << "[M] Main Menu\n"
- << "[T] Try Again\n"
- << "[E] Exit\n"
- << "Enter your choice: ";
- cin >> option;
- switch (option) {
- case 'M':
- case 'm':
- return;
- case 'T':
- case 't':
- activityOne();
- return;
- case 'E':
- case 'e':
- exit(1);
- default:
- cout << "Invalid option. Please try again!" << endl;
- break;
- }
- }
- }
- void activityTwo() {
- double totalGross, philHealth, sss, tax, pagIbig, deduction, salary;
- int hourlyRate, hoursOfWork, daysOfWork, absences, tardiness;
- char option;
- cout << "\n============Welcome to Activity #2============\n" << endl;
- cout << "-- Payroll System -- Daily Rate --\n\nEnter Hourly Rate : ";
- cin >> hourlyRate;
- cout << "Enter Hours of Work : ";
- cin >> hoursOfWork;
- cout << "Enter Days of Work : ";
- cin >> daysOfWork;
- cout << "Enter Absences : ";
- cin >> absences;
- cout << "Enter Tardiness or 0 if none: ";
- cin >> tardiness;
- totalGross = hourlyRate * hoursOfWork * daysOfWork;
- cout << "\nTOTAL GROSS: " << totalGross << endl;
- cout << "\nDeductions\n---------------\nPhilHealth: ";
- cin >> philHealth;
- cout << "SSS : ";
- cin >> sss;
- cout << "Tax : ";
- cin >> tax;
- cout << "Pagibig : ";
- cin >> pagIbig;
- cout << "Absences : " << absences << endl;
- cout << "Tardiness : " << tardiness << endl;
- cout << "---------------" << endl;
- absences = absences * 8 * hourlyRate;
- tardiness = tardiness * 50;
- deduction = philHealth + sss + tax + pagIbig + absences + tardiness;
- cout << "Total Deduction: " << deduction << endl;
- salary = totalGross - deduction;
- cout << "\nTOTAL SALARY : " << salary << endl;
- yesOrNo:
- cout << "\nGo back to Main Menu? [Y/N]: ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- exit(1);
- }
- else {
- cout << "INVALID INPUT!" << endl;
- goto yesOrNo;
- }
- }
- using namespace std;
- void activityThree()
- {
- cout << "\n============Welcome to Activity #3============\n" << endl;
- string itemName;
- double price, total = 0, grandTotal = 0, discountAmount = 0;
- int quantity;
- char addMore, withDiscount;
- const double DISCOUNT_PERCENTAGE = 0.1;
- cout << "---------------------------" << endl;
- cout << " CASH REGISTER " << endl;
- cout << "---------------------------" << endl;
- do {
- cout << "Enter item name: ";
- cin.ignore(); // Ignore the newline character left by previous cin
- getline(cin, itemName);
- cout << "Enter price: ₱";
- cin >> price;
- cout << "Enter quantity: ";
- cin >> quantity;
- double itemTotal = price * quantity;
- total += itemTotal;
- grandTotal = total;
- cout << "Apply discount? (Y/N): ";
- cin >> withDiscount;
- if (withDiscount == 'Y' || withDiscount == 'y') {
- discountAmount = total * DISCOUNT_PERCENTAGE;
- grandTotal = total - discountAmount;
- }
- cout << setprecision(2) << fixed;
- cout << "---------------------------" << endl;
- cout << "Item: " << itemName << endl;
- cout << "Price: ₱" << price << endl;
- cout << "Quantity: " << quantity << endl;
- cout << "Total: ₱" << itemTotal << endl;
- cout << "---------------------------" << endl;
- cout << "Total: ₱" << total << endl;
- cout << "Add another item? (Y/N): ";
- cin >> addMore;
- cin.ignore(); // Ignore the newline character left by cin
- } while (addMore == 'Y' || addMore == 'y');
- cout << "---------------------------" << endl;
- cout << "Grand Total: ₱" << grandTotal << endl;
- cout << "Discount: ₱" << discountAmount << endl;
- cout << "---------------------------" << endl;
- char option;
- optionSelection:
- cout << "\nSelect an option:\n"
- << "[M] Main Menu\n"
- << "[T] Try Again\n"
- << "[E] Exit\n"
- << "Enter your choice: ";
- cin >> option;
- switch (option) {
- case 'M':
- case 'm':
- main();
- break;
- case 'T':
- case 't':
- activityThree();
- break;
- case 'E':
- case 'e':
- cout << "Exiting..." << endl;
- break;
- default:
- cout << "Invalid option. Please try again." << endl;
- goto optionSelection;
- }
- cout << "\n============================================\n" << endl;
- }
- void activityFour() {
- cout << "\n============Welcome to Activity #4============\n" << endl;
- 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;
- selection:
- cout << "Enter Selection: ";
- cin >> option;
- if (option == 'a' || option == 'A') {
- rectangle();
- }
- else if (option == 'b' || option == 'B') {
- square();
- }
- else if (option == 'c' || option == 'C') {
- triangle();
- }
- else if (option == 'd' || option == 'D') {
- circle();
- }
- else if (option == 'e' || option == 'E') {
- cout << "\nThank you for using this program! :)" << endl;
- exit(1);
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
- goto selection;
- }
- }
- void rectangle() {
- cout << "\n==Welcome to Area of Rectangle==\n\nEnter the Length: ";
- cin >> length;
- cout << "Enter the Width : ";
- cin >> width;
- double areaOfRectangle = width * length;
- cout << "The Area of the Rectangle is: " << areaOfRectangle << endl;
- selection:
- cout << "Go back to Main Menu? [Y/N] : ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- cout << "\nThank you for using this program! :)" << endl;
- exit(1);
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
- goto selection;
- }
- return;
- };
- void square() {
- cout << "\n==Welcome to Area of Square==\n\nEnter the side: ";
- cin >> side;
- double areaOfsquare = side * side;
- cout << "The Area of the Square is : " << areaOfsquare << endl;
- selection:
- cout << "Go back to Main Menu? [Y/N] : ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- cout << "\nThank you for using this program! :)" << endl;
- exit(1);
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
- goto selection;
- }
- return;
- };
- void triangle() {
- cout << "\n==Welcome to Area of Triangle==\n\nEnter the Base : ";
- cin >> base;
- cout << "Enter the Height: ";
- cin >> height;
- double areaOfTriangle = 0.5 * (base * height);
- cout << "The Area of the Triangle is : " << areaOfTriangle << endl;
- selection:
- cout << "Go back to Main Menu? [Y/N] : ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- cout << "\nThank you for using this program! :)" << endl;
- exit(1);
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
- goto selection;
- }
- return;
- };
- void circle() {
- cout << "\n==Welcome to Area of Circle==\n\nEnter the radius : ";
- cin >> radius;
- double areaOfCircle = pi * (radius * radius);
- cout << "The Area of the Circle is : " << areaOfCircle << endl;
- selection:
- cout << "Go back to Main Menu? [Y/N] : ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- cout << "\nThank you for using this program! :)" << endl;
- exit(1);
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!\n\n";
- goto selection;
- }
- }
- void activityFive() {
- float firstNum, secondNum;
- char option;
- cout << "\n============Welcome to Activity #5============\n" << endl;
- cout << "===Welcome to Calculator Program===\n[A] Addtion\n[B] Subtraction\n[C] Multiplication\n[D] Division" << endl;
- yesOrNo:
- cout << "Enter your choice (A-D): ";
- cin >> option;
- if (option == 'a' || option == 'A') {
- cout << "Enter First Number : ";
- cin >> firstNum;
- cout << "Enter Second Number : ";
- cin >> secondNum;
- cout << "\nResult = " << additionFunction(firstNum, secondNum) << endl;
- yesOrNo1:
- cout << "\nGo back to Main Menu? [Y/N]: ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- exit(1);
- }
- else {
- cout << "INVALID INPUT!" << endl;
- goto yesOrNo1;
- }
- }
- else if (option == 'b' || option == 'B') {
- cout << "Enter First Number : ";
- cin >> firstNum;
- cout << "Enter Second Number : ";
- cin >> secondNum;
- cout << "\nResult = " << subtractionFunction(firstNum, secondNum) << endl;
- yesOrNo2:
- cout << "\nGo back to Main Menu? [Y/N]: ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- exit(2);
- }
- else {
- cout << "INVALID INPUT!" << endl;
- goto yesOrNo2;
- }
- }
- else if (option == 'c' || option == 'C') {
- cout << "Enter First Number : ";
- cin >> firstNum;
- cout << "Enter Second Number : ";
- cin >> secondNum;
- cout << "\nResult = " << multiplicationFunction(firstNum, secondNum) << endl;
- yesOrNo3:
- cout << "\nGo back to Main Menu? [Y/N]: ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- exit(3);
- }
- else {
- cout << "INVALID INPUT!" << endl;
- goto yesOrNo3;
- }
- }
- else if (option == 'd' || option == 'D') {
- cout << "Enter First Number : ";
- cin >> firstNum;
- cout << "Enter Second Number : ";
- cin >> secondNum;
- cout << "\nResult = " << divisionFunction(firstNum, secondNum) << endl;
- yesOrNo4:
- cout << "\nGo back to Main Menu? [Y/N]: ";
- cin >> option;
- if (option == 'y' || option == 'Y') {
- cout << "\n\n";
- main();
- }
- else if (option == 'n' || option == 'N') {
- exit(4);
- }
- else {
- cout << "INVALID INPUT!" << endl;
- goto yesOrNo4;
- }
- }
- else {
- cout << "INVALID INPUT PLEASE TRY AGAIN!" << endl;
- goto yesOrNo;
- }
- }
- float additionFunction(float numOne, float numTwo) {
- return numOne + numTwo;
- };
- float subtractionFunction(float numOne, float numTwo) {
- return numOne - numTwo;
- };
- float multiplicationFunction(float numOne, float numTwo) {
- return numOne * numTwo;
- };
- float divisionFunction(float numOne, float numTwo) {
- return numOne / numTwo;
- };
Advertisement
Add Comment
Please, Sign In to add comment