السلام عليكم
لدي واجب بالجامعة مطلوب مني بإختصار كالتالي:
ان هناك شخص عنده راس مال في بنك وهناك فائدة ايضا سنوية على راس المال المودع بالبنك
إضافة الى ايداعه كل شهر مبلغ معين
وهو يريد ان يشتري سلعة بسعر معين
بعد كم شهر يستطيع ان يشتري السلعة بشرط ان يبقى رصيده بالبنك لايقل عن10000
كمثال:
شخص عنده راس مال 20000
والنسبة الفائدة هي سنويا12
ايداعه شهريا 400
يريد شراء سلعة بـ 16250
طبعا على المثال هو يستطيع ان يشتري تلك السلعة بعد 11 شهر لكي يضمن ان لايقل حسابه عن 10000
عملت الكود بس احتاج من يساعدني فيه
#include <vcl.h>
#include "MT262io.h"
#include <math.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
int Capital;
int AnnualPercentage;
int Saving;
int Price;
int Month;
int Percentage;
Capital= ReadIntPr("Enter your capital: ");
AnnualPercentage= ReadIntPr("Enter the annual percentage: ");
Saving= ReadIntPr("Enter your saving per month: ");//Monthly deposit money in the bank
Price= ReadIntPr("Enter price of the item: ");
Percentage= ceil(Capital*AnnualPercentage/100/12);//ceil function for rounds a number upwards
Month= ceil((float)(Price-(Capital-10000))/(float)(Saving+Percentage));//Number of months
if(Month>0)
{
WriteIntPr("\n\nIf the capital is ", Capital);
WriteIntPr(" and the annual percentage rate on it is ",AnnualPercentage);
WriteIntPr("% and the monthly saving is ", Saving);
WriteIntPr(" You can buy the item after: ", Month );
WriteString(" Months");
}
else
{
WriteIntPr("\n\nIf the capital is ", Capital);
WriteIntPr(" and the annual percentage rate on it is ",AnnualPercentage);
WriteIntPr("% and the monthly saving is ",Saving);
WriteString(" You can buy the item right away! ");
}
getchar();
return 0;
}
//---------------------------------------------------------------------------