#include <iostream>
#include <stdio.h>
#include <stdbool.h>
#include <string>

struct dbit {
	bool bit1;
	bool bit2;
};

dbit BinaryAdd(bool num1, bool num2) {
	dbit ret;
	bool store;
	bool carry;
	
	//if statements for each possibility
	if(num1 == 1 && num2 == 1) { // 1 + 1
		store = 0;
		carry = 1; //carry the 1 over to the next digit
	}
	
	if(num1 ==  0 && num2 == 0) { // 0 + 0
		store = 0;
		carry = 0; //nothing
	}
	
	if(num1 == 1 && num2 == 0) { //1 + 0
		store = 1; //just 1
		carry = 0;
	}
	
	if(num1 == 0 && num2 == 1) {//0 + 1
		store = 1; //just 1
		carry = 0;
	}
	
	//put values into struct because we can't return two variables from a function
	ret.bit1 = store;
	ret.bit2 = carry;
	
	//and return that value containing the store and carry
	return ret;
}

int main() {
	//create variables for input/output
	bool input_bit1;
	bool input_bit2;
	dbit output;

	//write title
	std::cout << "Binary Calculator\n";

	//send user message to collect input
	std::cout << "Use the 'input' tab to choose which single-digit binary numbers to add\n";	
	std::cin >> input_bit1;
	std::cin >> input_bit2;

	//run function
	output = BinaryAdd(input_bit1, input_bit2);

	//write output
	std::cout << "Well, if we add " << std::to_string(input_bit1) << " and " << std::to_string(input_bit2) << ", we get " << std::to_string(output.bit2) << std::to_string(output.bit1);

	//close program
	return 0;
}