2016-07-27 8 views
-1

27/07/2016の方針を購入したと仮定した場合、次回のデートは27/08/2016です。
分割払いで支払われなかった人は、分割払いのために15日間延長されます。
彼がそうすることができなかった場合、彼はポリシーアウントメントの2%をうまく与えなければなりませんでした。ポリシー日付と割賦日付に応じて毎月細かい金額を計算する

は今、シナリオがある -

27/08/2016 =前の2ヶ月の罰金を支払わ=、
27/09/2016 =有給ない、
27/10/2016有料わけではありません。

だから、このような何かがそれを行うべきC#

+0

あなたは新しいstackoverflowを希望しています。これを見てくださいhttp://stackoverflow.com/help/how-to-ask –

+0

また、あなたが試したこととどこに問題があるかを示してください。 –

+0

if(extdate

答えて

0

でこれを計算する方法。

public decimal CalculatePayment() 
    { 
     DateTime lastPaymentDueDate = new DateTime(2016, 7, 27); 
     DateTime thisPaymentDate = new DateTime(2016, 10, 27); 

     decimal policy = 10000.0M; 
     decimal mthFee = 5000.0M; 
     decimal mthFine = policy * 2.0M/100.0M; 
     decimal payAmount = 0.0M; 
     DateTime nextPaymentDueDate = lastPaymentDueDate.AddMonths(1); 

     int thisPayJulian = (int)thisPaymentDate.ToOADate(); 
     int nextDueJulian = (int)nextPaymentDueDate.ToOADate(); 

     if (thisPayJulian < nextDueJulian) 
     { 
      //nothing to pay 
      return payAmount; 
     } 
     while (thisPayJulian - nextDueJulian > 15) 
     { 
      //deal with late payments 
      payAmount += mthFine + mthFee; 
      nextPaymentDueDate = nextPaymentDueDate.AddMonths(1); 
      nextDueJulian = (int)nextPaymentDueDate.ToOADate(); 
     } 
     if (thisPayJulian >= nextDueJulian) 
     { 
      //deal with regular payments 
      payAmount += mthFee; 
     } 
     return payAmount; 
    } 

は明らかに現実の世界では、lastPaymentDueDate、thisPaymentDate、および政策、料金及び罰金割合は、すべてのように、ここでのパラメータではなく、固定変数であるだろうが、私はあなたのアイデアを得る願っています。

しかし、他のコメントをもう一度繰り返す必要があります。一般的に、あなたがやったよりもむしろ自分のコードをもっと表示しないと、人々はあまり助けてくれることはありません。

関連する問題