📜  查找盈亏平衡点的程序

📅  最后修改于: 2021-05-07 06:45:51             🧑  作者: Mango

给出每月支出清单

\sum exp

组织的售价

S

和开销维护

M

每个项目的任务是计算收支平衡点。
盈亏平衡点是指为了抵消总支出而售出的商品数量,即总体而言,既没有利润也没有亏损。
例子:

方法:

  1. 计算所有支出的总和。
  2. 从售价中减去维护费用(成本价)。
  3. 将支出金额除以上述获得的金额,即可获得最少的要出售商品的数量(零点平衡点)。

下面是上述方法的实现:

C++
// C++ program to find the break-even point.
 
#include 
#include 
using namespace std;
 
// Function to calculate Break Even Point
int breakEvenPoint(int exp, int S, int M)
{
    float earn = S - M;
 
    // Calculating number of articles to be sold
    int res = ceil(exp / earn);
 
    return res;
}
 
// Main Function
int main()
{
    int exp = 3550, S = 90, M = 65;
    cout << breakEvenPoint(exp, S, M);
    return 0;
}


Java
// Java program to find Break Even Point
import java.io.*;
import java.lang.*;
 
class GFG
{
// Function to calculate
// Break Even Point
public static int breakEvenPoint(int exp1,
                                 int S, int M)
{
    double earn = S - M;
     
    double exp = exp1;
 
    // Calculating number of
    // articles to be sold
    double res = Math.ceil(exp / earn);
 
    int res1 = (int) res;
     
    return res1;
}
 
// Driver Code
public static void main (String[] args)
{
    int exp = 3550, S = 90, M = 65;
    System.out.println(breakEvenPoint(exp, S, M));
}
}
 
// This code is contributed
// by Naman_Garg


Python 3
# Python 3 program to find
# Break Even Point
import math
 
# Function to calculate
# Break Even Point
def breakEvenPoint(exp, S, M):
     
    earn = S - M
 
    # Calculating number of
    # articles to be sold
    if res != 0:
      res = math.ceil(exp / earn)
    # if profit is 0, it will never make ends meet
    else:
      res = float('inf')
         
    return res
     
# Driver Code
if __name__ == "__main__" :
         
    exp = 3550
    S = 90
    M = 65
     
    print (int(breakEvenPoint(exp, S, M)))
 
# This code is contributed
# by Naman_Garg


C#
// C# program to find Break Even Point
using System;
 
class GFG
{
// Function to calculate
// Break Even Point
public static int breakEvenPoint(int exp1,
                                int S, int M)
{
    double earn = S - M;
     
    double exp = exp1;
 
    // Calculating number of
    // articles to be sold
    double res = Math.Ceiling(exp / earn);
 
    int res1 = (int) res;
     
    return res1;
}
 
// Driver Code
public static void Main ()
{
    int exp = 3550, S = 90, M = 65;
    Console.WriteLine(breakEvenPoint(exp, S, M));
}
}
 
// This code is contributed
// by inder_verma..


PHP


Javascript


输出:
142