الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أريد شرح لهذا البرنامج؟؟؟

مغلق
بدأه Moon Land في 26 يوليو 2007 · 2 رد · 695 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لو سمحتوا أبغى شرح لهذا البرنامج و كيف يعمل:

#include<iostream>
using namespace std;
int main()
{
double balance = 50.00;
int count = 0;
cout<<"This program tells you how long it takes"<<endl;
<<"to accumulate a dept of $100 , starting with "<<endl;
<<"an initial balance of $50 owed. "<<endl;
<<"The interest rate is 2% per month . "<<endl;
while(balance <100.00)
{
balance=balance +0.02*balance;
count++;
}
cout<<"After "<<count <<"monthes,"<<endl;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"Your balance due will be $"<<balance <<endl;
return 0;
}

و لكم جزيل الشكر ....

#2

أولاً كان به أخطاء و ها هو الكود الصحيح

#include<iostream>
using namespace std;
int main()
{
double balance = 50.00;
int count = 0;
cout<<"This program tells you how long it takes"<<endl
<<"to accumulate a dept of $100 , starting with "<<endl
<<"an initial balance of $50 owed. "<<endl
<<"The interest rate is 2% per month . "<<endl;
while(balance <100.00)
{
balance=balance +0.02*balance;
count++;
}
cout<<"After "<<count <<"monthes,"<<endl;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"Your balance due will be $"<<balance <<endl;
system("pause");
return 0;
}

و هو كما ترى يحسب الفوائد (الربوية) على الديون

يقول لك شخص إستدان ب50 دولار

و كل شهر الفائدة (الربوية) تزيد 2%

فكم شهر يجعل الدين + الفوائد أكبر من 100 ؟؟

هنا

while(balance <100.00)
{
balance=balance +0.02*balance;
count++;
}

كان في السطر الثالث يزيد الفوائد و في نفس الوقت يزيد الشهور (في السطر الرابع)

و ينتهي هذا الأمر عندنا تزيد الفائدة (الربوية) على 100

ثم بعد ذلك يطبع النتيجة

#3

Thanks alot

شكرا جزيلا على الشرح الوافي ....

هذا الموضوع مغلق.

مواضيع مشابهة