title: Calculate Gross Profit W/O Sell
body: <p>Trying to make myself a small project for work that will calculate gross profit without needing a sell price. Can anyone explain why this is getting marked down? we all needed help at one point..</p>
  
  <p>I currently have 4 text boxes, Cost, Sell, Gross Profit Margin, Markup</p>
  
  <p>How i normally do it it excel is <code>=Cost/(1-Gp Markup)</code> and this would return $14.99 sell @ $12.74 cost for example @ 15%</p>
  
  <p>My code is below any help would be appreciated :)</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
     double cost = Convert.ToDouble(costTextBox.Text);
     double grossmargin = Convert.ToDouble(grossmarginTextBox.Text);
     double grossSellFinal = cost + (cost * grossmargin)/100;
     // This returns $14.65 which is a mark up not gross profit
     sellTextBox.Text = grossSellFinal.ToString();
  }
  </code></pre>
  
  <p>I have also tried this</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
     double cost = Convert.ToDouble(costTextBox.Text);
     double grossmargin = Convert.ToDouble(grossmarginTextBox.Text);
     double grossSellFinal = cost / (1 - grossmargin);
     //This returns a sell of -0.91
     sellTextBox.Text = grossSellFinal.ToString();
  }
  </code></pre>
  
  <p><a href="https://www.calculatorsoup.com/calculators/financial/margin-calculator.php?cost=12.74&amp;revenue=14.99&amp;action=solve" rel="nofollow noreferrer">https://www.calculatorsoup.com/calculators/financial/margin-calculator.php?cost=12.74&amp;revenue=14.99&amp;action=solve</a></p>