Added more spacing in program, added new installation option and added ".gitignore"
This commit is contained in:
parent
52079b95b5
commit
5cfccfdf49
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
Calculator
|
||||
CalculatorIcon.png
|
|
@ -6,14 +6,16 @@
|
|||
double total_num;
|
||||
int end_option;
|
||||
int option;
|
||||
bool loop = true;
|
||||
int main()
|
||||
{
|
||||
bool loop = true;
|
||||
while (loop)
|
||||
{
|
||||
std::cout << "Please select an option from the list:\n";
|
||||
std::cout << "1: Add | 2: Subtract | 3: Divide | 4: Multiply | 5: Square root \n";
|
||||
std::cout << "\n";
|
||||
std::cin >> option;
|
||||
std::cout << "\n";
|
||||
switch (option)
|
||||
{
|
||||
case 1:
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "CalculatorFunctions.h"
|
||||
using namespace std;
|
||||
static double ans = 0;
|
||||
bool loop2 = true;
|
||||
double math(std::string text, std::function<double(double, double)> code, bool use_last_num, std::string math_symbol)
|
||||
{
|
||||
double total_num = 0;
|
||||
|
@ -19,17 +20,21 @@ double math(std::string text, std::function<double(double, double)> code, bool u
|
|||
std::cin >> num2;
|
||||
total_num = code(num1, num2);
|
||||
ans = total_num;
|
||||
std::cout << "\n";
|
||||
std::cout << num1 << math_symbol << num2 << " = " << total_num << "\n";
|
||||
} else {
|
||||
|
||||
total_num = 0;
|
||||
std::cout << text << "\n";
|
||||
std::cout << "Fetching last number...\n";
|
||||
std::cout << ans << "\n";
|
||||
std::cout << "Please enter the number here: \n";
|
||||
std::cin >> num2;
|
||||
total_num = code(num2, ans);
|
||||
std::cout << ans << math_symbol << num2 << " = " << total_num << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << text << "\n" << "\n";
|
||||
std::cout << "Fetching last number...\n";
|
||||
std::cout << ans << "\n";
|
||||
std::cout << "Please enter the number here: \n";
|
||||
std::cin >> num2;
|
||||
total_num = code(num2, ans);
|
||||
std::cout << "\n";
|
||||
std::cout << ans << math_symbol << num2 << " = " << total_num << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
return total_num;
|
||||
}
|
||||
|
@ -45,6 +50,7 @@ double square_root(std::string text, bool use_last_num)
|
|||
total_num = sqrt(sqrt_num);
|
||||
ans = total_num;
|
||||
std::cout << "The square root of " << sqrt_num << " = " << total_num << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
30
Installer.sh
30
Installer.sh
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
echo "Compiling..."
|
||||
clang++ Calculator.cpp CalculatorFunctions.cpp -std=c++17 -o CalculatorExec
|
||||
echo "Done!"
|
||||
echo "Cleaning up..."
|
||||
sleep 1
|
||||
mkdir ${HOME}/CalculatorFiles
|
||||
mv CalculatorExec ${HOME}/CalculatorFiles
|
||||
desktop_file='Calculator.desktop'
|
||||
cat >"$desktop_file" <<-EOF
|
||||
[Desktop Entry]
|
||||
Name=Calculator
|
||||
Exec=${HOME}/CalculatorFiles/CalculatorExec
|
||||
Terminal=true
|
||||
Comment="Calculator for simple math problems."
|
||||
Type=Application
|
||||
EOF
|
||||
mv Calculator.desktop ${HOME}/Desktop
|
||||
chmod +x ${HOME}/Desktop/Calculator.desktop
|
||||
rm -rf ${HOME}/Terminal-Based-Calculator
|
||||
echo "Done!"
|
||||
echo "Now enjoy your calculator :)!"
|
||||
echo "Closing in:"
|
||||
echo "3"
|
||||
sleep 1
|
||||
echo "2"
|
||||
sleep 1
|
||||
echo "1"
|
||||
sleep 1
|
||||
exit
|
56
Makefile
Normal file
56
Makefile
Normal file
|
@ -0,0 +1,56 @@
|
|||
# Makefile for Terminal-Based-Calculator
|
||||
# Project by T4rtP1ck13 (https://github/com/T4rtP1ck13)
|
||||
# Makefile by Bowuigi (https://github.com/Bowuigi)
|
||||
|
||||
IN=$(wildcard *.cpp)
|
||||
OUT=tbc
|
||||
CPPFLAGS=-std=c++17 -Os
|
||||
CPP=c++
|
||||
STRIP=strip
|
||||
DESTDIR=/usr/local/bin
|
||||
DESKTOPDIR=/usr/local/share/applications
|
||||
DESKTOPFILE=Calculator.desktop
|
||||
|
||||
build:
|
||||
@echo "Compiling..."
|
||||
$(CPP) $(IN) $(CPPFLAGS) -o $(OUT)
|
||||
$(STRIP) $(OUT)
|
||||
@echo "Done!"
|
||||
@echo "Enjoy your calculator!"
|
||||
|
||||
install: build
|
||||
@echo "Installing to" $(DESTDIR) "..."
|
||||
mkdir -p $(DESTDIR)
|
||||
cp $(OUT) $(DESTDIR)
|
||||
@echo "Done!"
|
||||
|
||||
desktop: install
|
||||
rm -f $(DESKTOPFILE)
|
||||
@echo "Creating the desktop file..."
|
||||
|
||||
echo "[Desktop Entry]" > $(DESKTOPFILE)
|
||||
echo "Name=Calculator" >> $(DESKTOPFILE)
|
||||
echo "Exec=" $(DESTDIR)/$(OUT) >> $(DESKTOPFILE)
|
||||
echo "Terminal=true" >> $(DESKTOPFILE)
|
||||
echo "Comment='Calculator for simple math problems'" >> $(DESKTOPFILE)
|
||||
echo "Type=Application" >> $(DESKTOPFILE)
|
||||
echo "Icon=${HOME}/CalculatorFiles/CalculatorIcon.png" >> $(DESKTOPFILE)
|
||||
|
||||
@echo "Copying the desktop file to" $(DESKTOPDIR) "..."
|
||||
mkdir -p $(DESKTOPDIR)
|
||||
cp $(DESKTOPFILE) $(DESKTOPDIR)
|
||||
cp $(DESKTOPFILE) $(HOME)/Desktop
|
||||
@echo "Done!"
|
||||
|
||||
clean:
|
||||
@echo "Cleaning..."
|
||||
rm -f $(OUT)
|
||||
@echo "Done!"
|
||||
|
||||
uninstall:
|
||||
@echo "Uninstalling..."
|
||||
rm -f $(DESTDIR)/$(OUT)
|
||||
rm -f $(DESKTOPDIR)/$(DESKTOPFILE)
|
||||
@echo "Done!"
|
||||
|
||||
.PHONY: build desktop install clean uninstall
|
Reference in a new issue