تسجيل الدخول

مشاهدة النسخة كاملة : سؤال في السي++



sondos
08-11-2005, 08:12 AM
السلام عليكم



ممكن تفهموني هذا السؤال لان لم حاولت احله لقيت نفسي ماا حقق المطلوب ممكن تشرحون لي عشان اسوي الكود صح

السؤال هو




A motor insurance company has surveyed a sample of its clients. The information

on each returned questionnaire includes the following:

o whether the client has had a claim in the last twelve months;

o the age of the client (in whole years at last birthday).



(Each returned questionnaire is referred to as a `return' for short.)



A program is required to analyse this information. A keyboard operator is to input

the data by responding to the following screen prompts.



Has the client claimed in the last 12 months?

Enter Y (for Yes), N (for No) or S (to stop processing):

and

Age of client?





When all data has been entered, the program is to output three numbers. These

are the total number of returns analysed, the number who have made a claim, and

the number who have made a claim and are under 25. Typical output might be as

follows.

Number of returns analysed = 685

Number of claimants = 131

Number of claimants who are under 25 = 79



The program is to be based on the following top-level design.



1 initialise variables

2 loop while there are more returns to be processed

3 process next return

4 loopend

5 write out results



Step 3 will involve reading in the data from the next return - a character value in response to the first prompt and an integer value in response to the second prompt - and updating counts accordingly. Note that the client's age is requested for all returns, not just for those where a claim has been made.




As it is not known in advance how many returns there are going to be, the loop will

have to be controlled by operator input. To indicate the end of input, the sentinel value `S' is to be entered in response to the first of the screen prompts.



a) Refine this design to a final design ready for coding into C++. You are to assume that the operator enters data correctly, so your design must not include any data validation. Submit your final design, which should include a data table, to your tutor. [15]

وشكرا لكل المشاركين

The Coder
09-11-2005, 03:47 AM
طيب طيب
ان شاء الله اقدر اساعدك .. رغم ان اللغة عندي سيئة ...
ان شاء الله بكرة او بعده ... اشرح لك .. هذا اذا لم يشرح احد قبلي ...

The Coder
10-11-2005, 10:49 PM
اسف ..
تأخرت كثيرا ..
لقد نسيت منك ..
قرأت البرنامج ..
وهناك نقطة لم افهمها ..
ولكن سوف اقول لك .. ما فهمته ..

داخل دوارة لا نهائية ...
يطلب البرنامج مايلي :
Has the client claimed in the last 12 months?؟؟؟

اذا تم اختيار y ... نعم ..
اذا تم اختيار N .. لا ...
اذا تم اختيار S .. يعني طباعة النتائج والخروج من البرنامج

اذا ضغط نعم او لا ....
فسوف يطلب عمر هذا الزبون
ويتم ادخال عمر الزبون الحالي ..
سوف تتكرر الحالة مع الزبائن كلهم الى اللا نهائية ... حتى يتم ادخال S
النتائج تكون ثلاث ارقام ..
الرقم الاول لا اعرفه ...
الرقم الثاني .. عدد الزبائن (عداد) ... الذين تم السوال عنهم ..
الرقم الثالث .. هو عدد الذين تقل اعمارهم عن 25 سنة ....

هذا الي فهمته ....
واسف .. لانني لم اعرف الرقم الاول ..


هل فهمت شي من شرحي ؟؟ او اعيد بصيغة ثانية ..

ارجو ان تريني انت ماذا فهمت منه ....
موفقين

sondos
14-11-2005, 10:22 AM
شكرا للاهتمام والرد علي الموضوع
لكن بصراحة مو فاهمة السؤال عدل عشان كذي ما عرفت اسوي الكود
لان لم اسوي الاسئلة اخزن الاجابات في ثلاث متغيرات ثم اسوي جملة ًwhile اذا كانت الاجابة لا تساوي s ,وبعدين امشي بطريقين اذا كانت الاجابة N والطريق الثاني لما تكوزن الاجابة Y
لكن لم جيت اكتب الكود لقيت نفسي مو فاهمة عدل

The Coder
15-11-2005, 05:02 AM
شكرا للاهتمام والرد علي الموضوع
لكن بصراحة مو فاهمة السؤال عدل عشان كذي ما عرفت اسوي الكود
لان لم اسوي الاسئلة اخزن الاجابات في ثلاث متغيرات ثم اسوي جملة ًwhile اذا كانت الاجابة لا تساوي s ,وبعدين امشي بطريقين اذا كانت الاجابة N والطريق الثاني لما تكوزن الاجابة Y
لكن لم جيت اكتب الكود لقيت نفسي مو فاهمة عدل

اعطيني الكود بتاعك ... او محاولاتك .. وانا اعدل ..
ولو تبين .. احلهم لك ..
بس متى اخر موعد .. لاني ما حأفضى الا يوم الخميس ....والجمعة والسبت ..... الخ

sondos
17-11-2005, 07:46 AM
السلام عليكم
الكود هو




#include <vcl.h>

#pragma hdrstop



//---------------------------------------------------------------------------



#pragma argsused

int main(int argc, char* argv[])

{

string claiment=ReadPrIn("has the client claimed in the last 13 months");

int age=ReadInPr"enter your age";



int count=0;

int claims25=0;

int cliams=0;

int returns=count+claims25;

while(claims!=s)

if( claiment=y)&(age<25)

claims25=claims25+1;count+1;

if(claiment=n)

count=count+1 ;

WriteString("Numbers of returns analysed ="+"returns"/n"number of claimts ="+"claims"/n"number of claimts who are under 25="+"claims25 ")









return 0;

}

//-------------------------------------------------------
وياليت ترد علي خلال هلاسبوع
وشكرا لك

sondos
17-11-2005, 07:47 AM
السلام عليكم
الكود هو





#include <vcl.h>

#pragma hdrstop



//---------------------------------------------------------------------------



#pragma argsused

int main(int argc, char* argv[])

{

string claiment=ReadPrIn("has the client claimed in the last 13 months");

int age=ReadInPr"enter your age";



int count=0;

int claims25=0;

int cliams=0;

int returns=count+claims25;

while(claims!=s)

if( claiment=y)&(age<25)

claims25=claims25+1;count+1;

if(claiment=n)

count=count+1 ;

WriteString("Numbers of returns analysed ="+"returns"/n"number of claimts ="+"claims"/n"number of claimts who are under 25="+"claims25 ")









return 0;

}

//-------------------------------------------------------

ويا ليت ترد علي خلا هلااسبوع
وشكرا

The Coder
18-11-2005, 02:54 AM
السلام عليكم
الكود هو





#include <vcl.h>

#pragma hdrstop



//---------------------------------------------------------------------------



#pragma argsused

int main(int argc, char* argv[])

{

string claiment=ReadPrIn("has the client claimed in the last 13 months");

int age=ReadInPr"enter your age";



int count=0;

int claims25=0;

int cliams=0;

int returns=count+claims25;

while(claims!=s)

if( claiment=y)&(age<25)

claims25=claims25+1;count+1;

if(claiment=n)

count=count+1 ;

WriteString("Numbers of returns analysed ="+"returns"/n"number of claimts ="+"claims"/n"number of claimts who are under 25="+"claims25 ")









return 0;

}

//-------------------------------------------------------

ويا ليت ترد علي خلا هلااسبوع

وشكرا


ولو ماني عارف ما معنى "هالاسبوع" ولكن ... حأحاول افضى .... حأحاول بالتأكيد ..

والمعذرة لو فيه قصور مننا

The Coder
18-11-2005, 11:09 AM
على فكرة

هذا كود غريب علي ..
سوري .. بس والله صرت الخبط بين السي والسي ++ والجافا وووو .....

مافهمت وش الي تبيه ؟؟؟
يعني هالكود شغال او لا ؟؟
ولا ..... هذا مش كود .. هذا كود توضيحي وليس كود شغال وتبين نحوله الى كود سي ++ يشتغل ؟؟؟

مش فاااااااهم بالضبط وش المطلوب ...!!

AMTORNADO
21-12-2005, 08:05 PM
me 2!!!!!!!!!!