المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Help Me Plz in My C++ Assignment


Palestinian Rose
06-11-2007, 04:13 PM
Hi everybody

im a girl who studies Computer Science, and this is the first time for me to take a course related to programming or anything related to computer !! som im having really some troubles in my C++ course !!
I really need anyone's help who has studied CS or at least know anything about C++ programming language
i have a hard assignment which is due after few days !!
i tried all ways to solve it !! i asked alot of people to help me , and i searched in books and websites , but unfortunatly i couldnt do who of it !! it really needs much more from what i know !! im still a bigener , and i dont know that much about C++ !!! but the dr. gave us such hard assignment coz he wants us to try and to keep learning and searching !! and i swear that's what i did, but i didnt get any results !!! :icon5:


i'll attach u what we should do in the assignment and how it should be

Plzz see if u can help me and get me the code 4 that assignment

:b:

i'll really appreciate anyone's well and effort to help me
and i can show him or her what i've done in the assignment so far so he or she can help me adding or correcting my errors


Thnx Alot guys

waiting ur reply

Bye :s (43):

ABU-NOUR
06-11-2007, 04:57 PM
You are welcome !!
Here in these forum we will helped you ,

I will search for every thing that's important about
C++

but i'm not sure , if I can help you ..

However you welcome here .

what is your problem's ,

can you write arabic ?

best regards,
ABU-NOUR

~ | Mazaj
06-12-2007, 09:33 AM
I like to help you
but I do not know anything in that language,
God brothers here will Help

Greetings
Fajer

Palestinian Rose
06-12-2007, 11:34 AM
شكرًا على ردودكم و على استعدادكم لمساعدتي

Let me tell u more about the assignment.
The assignment is about opening a file and reading its components, like reading the number of its lines , or letters, or words, or digits …..
And then it gives u the result in an output file , and in the output black screen .


I tried so many times to attach u more information about the assignment and pictures of the output but it failed !!!! I don’t know why !!
But I'll try to attach them now again

I'll attach a handout which the dr. gave us to know what we have to use in solving the assignment and finding the input of the output we have .
I couldn’t send u the output it self, so I'll send u just pictures of it so u can see who it should be done .

Thanx a lot guys

Palestinian Rose
06-12-2007, 11:44 AM
Tell me how can i attach things related to the assignment :wacko:

sorry, لأنو هاي أول مرة الي أشارك في منتدى ،
so i dont know how to really use it !!

محمود
06-12-2007, 11:56 AM
اختي العزيزة

تفضلي هون شرح كامل لكل شي بتريديه

http://www.cplusplus.com/doc/tutorial/

ولو احتجتي مساعده راح اشرحلك المنطق البرمجي الها

كل التحية ,,

lnosh
06-12-2007, 11:56 AM
مراحب

انا بدرس برمجة حاسوب وبعرفة في لغة c ++

ويمكن اساعدك في الوظيفة

بس وين المشكلة عندك بالضبط ؟؟

ABU-NOUR
06-12-2007, 12:04 PM
تحياتنا الك ,, هي في ناس هين شاطرين بهالشغلات هذه ,,

ان شاء الله يساعدوكِ ..


اي شي تاني ,, مستعدين

lnosh
06-12-2007, 12:09 PM
أختي هون في شرح للغات البرمجة كاملة

http://n.domaindlx.com/cpplp/login.asp

http://www.arabteam2000.com/

بس رابط الموقع الي وضعه محمود ممتاز كتير

Palestinian Rose
06-12-2007, 01:36 PM
I'll show u how the output should be




File Processing
=========

1- Number of Lines
2- Number of Words
3- Number of Letters
4- Number of Digits
5- Number of Printable ASCII Characters
6- Quit
>_



// after u choose one of these selections, for example #1 , it will ask u to enter the name of ur input file name which u already have it somewhere in the pc :


You chose Menu Option #1
Enter You input File Name



// and after u enter ur input file name with its location for sure like this :


Enter Your input file name : C:\Book.in




//it will ask u then to enter ur output file name , and it can be any name u choose but not the same name as ur input file name

Enter Your output file name : C:\Face.out



//after u entered ur input and output file names , it will give u the result on the screen, which is the number of line or number of whatever u want to know in the file . and it will also put the results in the out put file name like this :

The number of lines in the file [C:\Book.in] is 12


// then it will display the menu again over and over



File Processing
=========

1- Number of Lines
2- Number of Words
3- Number of Letters
4- Number of Digits
5- Number of Printable ASCII Characters
6- Quit
>_


// thats it

i hope u understood what i want

i've made an code already but it lacks some things
i'll show u to it later if u want


bye

محمود
06-12-2007, 03:37 PM
السلام عليكم

اختي هنا شرح لمشروع مشابه جدا ً لمشروعك

تفضلي هون وراح تستفيدي

http://www.velocityreviews.com/forums/t287438-reading-numbers-of-words-and-lines-in-text-file-in-c.html

Palestinian Rose
06-12-2007, 04:13 PM
شكرًا يا أخ محمود

أنا تقريبًا سويت البرنامج ، مع أكيد كتير من المساعدات من النت و الأصدقاء
بس هو بس ناقصو شوية أشياء و بيكمل لحتى أسلمه

محمود
06-12-2007, 04:33 PM
اوك شو الي ناقص عندك هلا ؟

وشو الي مش فاهماه فيه ^_^

محمود
06-13-2007, 03:31 AM
اسف اختي بس كانت الكهرب قاطعه

شوفي هيك

#include<iostream> //for cin,cout
#include<fstream> //for file processing functions
#include<cctype> //for isalpha(), isdidgit(),....etc. functions
using namespace std;

void outputNumberOfLines(const char *inputFileName , const char *outputFileName);
void outputNumberOfWords(const char *inputFileName , const char *outputFileName);
void outputNumberOfLetters(const char *inputFileName , const char *outputFileName);
void outputNumberOfDigits(const char *inputFileName , const char *outputFileName);
void outputNumberOfPrintableCharacters(c onst char *inputFileName , const char *outputFileName);
int getMenuChoice();

char infile[256]; // Input File
char outfile[256];// Output File


int main()
{




//Optain desired option from user
switch(getMenuChoice())
{
case 1:
outputNumberOfLines(infile,outfile) ;
break;
case 2:
outputNumberOfWords(infile,outfile) ;
break;
case 3:
outputNumberOfLetters(infile,outfil e);
break;
case 4:
outputNumberOfDigits(infile,outfile );
break;
case 5:
outputNumberOfPrintableCharacters(i nfile,outfile);
break;
case 6:
/*


exit(1);

*/

break;
}
cout<<"Result was printed out to "<<outfile<<endl;



return 0;


}

int getMenuChoice()
{
//Choice to be entered by user
int ch;
cout<<"\t\tFile Processing"<<endl
<<"\t\t==============="<<endl
<<endl
<<"1- Number of Lines"<<endl
<<"2- Number of Words"<<endl
<<"3- Number of Lettters"<<endl
<<"4- Number of Digits"<<endl
<<"5- Number of Printable ASCII Characters"<<endl
<<"6- Quit"<<endl;

cout<<">";
cin>>ch;

cout<<endl;

cout<<"You Chose Menu Option #"<<ch<<endl;
cout<<"Enter your input file name: ";cin>>infile;
cout<<"Enter your output file name: ";cin>>outfile;


//Check if user entered invalid choice number
if(ch<1 || ch>6)
{
cout<<"No such option. Please enter a number from the list!"<<endl;
return getMenuChoice();
}
else
return ch;



}
void outputNumberOfLines(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios ::out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char line[1024]; // a line with max length 1024

//This extracts one line a time
inputFile.getline(line,1024);

count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Lines="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfWords(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char line[1024]; // a line with max 1024

//This extracts one word a time
inputFile>>line;

//don't count single letters
if(strlen(line)>1)
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Words="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfLetters(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only alphabet letters
if(isalpha(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Letters="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfDigits(const char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only digits letters
if(isdigit(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Digits="<<count<<endl;

//closing files
inputFile . close ();
outputFile . close ();
}
void outputNumberOfPrintableCharacters(c onst char *inputFileName , const char *outputFileName)
{
//opening file for input
ifstream inputFile (inputFileName , ios :: in );

//opening file for output
ofstream outputFile (outputFileName , ios :: out );

//checking file opening was successful
if (! inputFile )
{
cerr<<"Error opening file:\t"<<inputFileName<<endl ;
exit (1);
}
if (! outputFile )
{
cerr<<"Error opening file:\t"<<outputFileName<<endl ;
exit (1);
}

// a counter variable for no. of lines
int count=0;

//Loop until end-of-file
while(!inputFile.eof())
{
char c; // a line with max 1024

//This extracts one word a time
inputFile.get(c);

//count only printable chars
if(isprint(c))
count++;
}

//print count result to output file
outputFile<<"Filename: "<<outputFileName<<"\tNumber Of Printable Charachters="<<count<<endl;

//closing files
inputFile.close ();
outputFile.close ();
}

Palestinian Rose
06-13-2007, 08:14 AM
يعطيك العافية يا أخ محمود

بس و الله بصراحة الكود لساتو متل ما هو !! و عم يعطيني نفس النتائج اللي أنا عملتها من أول !!!!
يعني لسه المشاكل اللي فيه موجود !!!
يمكن انت حاولت تضيف Quit للكود ، بس برضو ال program ما بيعمل Quit لما تختار الخيار السادس اللي هو Quit !!!!!!!

عالعموم ، اذا ما حد عرف يساعدني مش مشكلة !! الله يعطيكم العافية على كل حال
انا بحاول أزبطه مرة تانية ، أو بسأل أي حد تاني يساعدني


شكرًا كتير للجميع

محمود
06-13-2007, 10:48 AM
مستحيل اختي ^_^

انا ما حطيت الخروج بس ..

بالعكس انا غيرت الشرط




//Check if user entered invalid choice number
if(ch<1 || ch>6)
{
cout<<"No such option. Please enter a number from the list!"<<endl;
return getMenuChoice();
}
else
return ch;

شوفي هون ^_^

وراح تفهمي لحالك انو الشرط كان محدود لـ 5

انا زودته وخليته لـ 6 حتى يقبلها ..

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

انو يطلع من البرنامج ..

حاولى مرة اخرى وراح يضبط معك

للعلم انا ما عندي كمبايلور وياريت تبعتيلي الي عندك

حتى اشوفلك اياه ..

كل التحية ..

Palestinian Rose
06-13-2007, 08:39 PM
مرحبا

آسفه على الرد المتأخر !! بس والله مشغولة بامتحاناتي و البحوث و الواجبات اللي ما بتخلص !!! :b:

و مش عارفه يا أخ محمود كيف أبعتلك اللي انت طلبتو !!! بس رح أحاول بعدين ان شا الله في ال weekend

بس انا متأكده ان الكود اللي انت عدلتلي ياه لسه ما تعدل !! و لسه بيعطيني نفس النتيجة !!!

its ok

انا ان شاء الله بحكي معك بعدين
لأني كتير مشغولة والله

مع الســــلامة

محمود
06-14-2007, 08:05 AM
اوكي اختي الكريمة ،،

اضغطي الملف وارفعيه على روسانا

www.rooosana.ps

وهاتي الرابط الي بطلع معك ، وانا بخدمتكـ ^^

Palestinian Rose
06-14-2007, 07:47 PM
مرحبا

بصراحة يا أخوي انا مش عارفة انت شو بالضبط بدك ياني أبعت !!!
بدك أبعتلك البرنامج اللي بيشغل الكود ، إللي هو Microsoft Visual C++ 6.0 ?!?
ولا قصدك أبعتلك ال output تبع الأستاذ اللي لازم نعمل متلو ؟؟؟

عالعموم ، أنا رح أبعتلك كل شي

فيك تنزل البرنامج تبع ال C+ من هاد الموقع : http://msdn2.microsoft.com/en-us/vstudio/aa718364.aspxأنا بصراحة نزلت البرنامج من CD كان موجود مع كتاب ال C+ !!

و جربت ابعتلك كل شي بيخص ال assignment على الموقع اللي انت قلتللي عليه
بس ال output تبع الأستاذ مش راضي ينبعت!! عشان هيك رح أبعث صور منو لحتى تشوف وين المشاكل و الاختلافات اللي في ال output تبعي و ال output تبع الأستاذ


هاي الأشياء اللي عملتلها upload في موقع Rooosana :

1) ال handout اللي أعطانا اياها الأستاذ اذا حابب تشوفها
http://www.rooosana.ps/Down.php?d=9ugB




2) الكود تبع ال assignment اللي أنا عملتو بعد ما عدلتو
و هو بصراحة تعدل الحين كتير عن أول بعد كتير من المساعدات
يعني هلأ صار يعمل Quit و يطلع من البرنامج ، و صار يطبع ال results في الoutput ..
بس برضو لساتو ناقصو شوية أشياء لحتى يصير تمامًا مطابق لتبع الأستاذ ، اللي هو طبعًا مطلوب منا !!
فإنت شوف الكود تبعي و اعملو run ، و رح أبعتلك متل ما قلت الصور من ال output تبع الأستاذ لحتى تشوف انت الفرق !!

هاد الكود تبعي
http://www.rooosana.ps/Down.php?d=jjpu




3) صور لل output تبع الأستاذ

1- picture of the MAIN MENU
http://www.rooosana.ps/Down.php?d=Ivyd

2- After choosing one of the menu selections
http://www.rooosana.ps/Down.php?d=FPaQ

3- Entering the name of the output and input files we want to open and read
http://www.rooosana.ps/Down.php?d=ASvu

4-Getting the result after reading the files , and then display the menu again
http://www.rooosana.ps/Down.php?d=rYM4

5- When choosing a selection not between (1-6) , the menu will be displayed again
http://www.rooosana.ps/Down.php?d=jYyU

6-Choosing to Quit from the whole program
http://www.rooosana.ps/Down.php?d=Qtx1

محمود
06-15-2007, 11:11 AM
اوك اختي انا بنزل البرنامج ،،

وبشوفلك اياه ،،

لاني انا مبرمج
java

javascript

php

C

pascal

QBasic


وبعض اللغات الخفيفة

انا قرأت الشروحات على اللغه لقيتها حلوة ^^

بس ما تقلقي البرمجة نفس الفكر يعني راح انزله واشوف المشكلة من وين

بالضبط ، على امل انو نصل حل للمشكلة مع اني متأكد انو المشروع تمام (:

بس راح اعاينه بنفسي ..

ABU-NOUR
06-16-2007, 08:39 AM
يعطيكم الف عافية ,,

Palestinian Rose
06-16-2007, 12:16 PM
الله يعطيك العافية يا أخ محمود
عن جد غلبتك معي !!!

بس طمني شو صار معك !!؟
انا مش عارفة إذا وصلك الكود تبعي مزبوط أو لأ !؟!
لأني لما فتحت ال link تبع الكود اللي انا بعتلك ياه لقيت الكود شوي ملخبط و كلو محطوط في كم سطر !! صح ؟
ف ما بعرف اذا قدرت تفهمو أو تعدلو و تشوف المشاكل اللي فيه !!

so im going to send u another one
رح أحط الكود في ال Ms word و أبعتلك ال link تبعو كمان مرة

http://www.rooosana.ps/Down.php?d=hf8k


و اذا ما عرفت الاختلافات او المشاكل اللي في الكود تبعي، ممكن انا اقولك اياها
هي اختلافات بسيطة بس :


أول شي انه لما تختار الخيار رقم 5 في ال menu، اللي هو Number of Printable ASCII Characters ، الكود تبعي يعطيك رقم ال ASCII characters الفايل بس +1 ، يعني يضيف على كل ناتج واحد !!!!!!!


ثاني مشكلة انه لما تختار Quit ، البرنامج يطلع صح ، بس المشكلة انه يقولك :
you chose menu option #6
you chose to Quit
انا عاد ما بدي ياه يقولي " you chose menu option #6 " !!!!
أنا بدي ياه بس يكتب " you chose to Quit " بعدين يطلع من البرنامج !!


المشكلة الثالثة و الأخيرة انه لما تختار اي خيار غير 1،2،3،4،5،6 ، يعني 9 أو 11 مثلا ً ، المفروض انه البرنامج يعمل display for the Menu بس من دون ما يقول اي شي تاني !
بس انا في الكود تبعي المشكلة انه يقولي you chose menu option #9 بعدين يعمل display لل menu !!!



هاي كل الأشياء اللي ناقصه الكود تبعي
و التسليم بكرة ان شاء الله
فإذا ما عرفت تسويها اليوم ، Dont worry , its ok :icon31:
u dont have to do it


and THANX ALOT 4 EVERYONE here
it was really a big pleasure 4 me to know u
:s (43):



wish me luck plz in my final exams which will be on 25/6

and i promise that i will be an active memeber here after i finish my finals :icon11:

Byezzz

Palestinian Rose
06-16-2007, 08:40 PM
مرحبا


هلأ خلص ، الحمد لله قدرت أعدل الكود بعد 100 محاولة :icon11:

يعني هلأ و الحمد لله صار جاهز للتسليم !


so THANK YOU VERY MUCH Mr.Mahmood
and thnx alot 4 everyone who was ready to hlep me
ur really good people and i really appreciate ur welling to help me


see u later nshallah :icon31:

bye
مع الســــــــلامة

محمود
06-16-2007, 10:44 PM
الله يسعدك اختي ^_^

بخدمتك بكل وقت ..

وخلينا نشوفك ..


وموفقة وبرمجتك حلوة ::

ABU-NOUR
06-17-2007, 08:28 AM
يعطيكم الف عافية ,, ^^
ان شاء الله بالتوفيق وجاهزين لخدماتك واي خدمة احنا مستعدين ..