Sean Merricks

Designer | Programmer | Data Guy

Coding

I really enjoy the problem solving of coding and I am self taught in several languages.

C++ Examples


C++ margin formula writer for Excel

Quick C++ program that writes you an Excel formula to calculate a margin based on your cost and sell price. It's almost like I get asked "how do I figure out a margin again?" all the time and just seeing if I could program it just popped into my head.

#include <iostream>

using namespace std;

main() {

  string sell, cost;
  int row;

  cout << "What column is your sell price in?";
  cin >> sell;

  cout << "What column is your cost price in?";
  cin >> cost;

  cout << "What row are you pasting into?";
  cin >> row;

  cout << "Copy and paste the following:" << endl;
  cout << "=(" << sell << row << "-" << cost << row << ")/" << sell << row;
  
}