Sunday, August 2, 2009

Language programming C,C++ and Java?

I havent ever learned the languages like C, C++ and Java


But as its necessary for my major i want to do java


Canany one help me guiding that shoulld i take C or C++ before doing my Java


By the way i will be majoring in Computer Science !

Language programming C,C++ and Java?
You can go with Java straight without having any knowledge of C or C++. After that you should learn C as well. I highly recommend it.





C++ is not really necessary, and I don't consider it as a good computer programming language.





--


Best,


Adeil
Reply:Hi


I am a Computer Science teacher. First you need to find out from your college what programming language is used in the first course. Most colleges have already switched to Java. In fact the AP exam has been in Java as of 2003. Other schools are using C++ but very few are starting out with C. Java is modeled after C++ so it won't be hard make a transition from one to the other. If you are not in college yet I highly recommend you start with Java and use the free tutorials at java.sun.com. Good luck.
Reply:Personally, I think that you should learn Java first. It is a good language to learn first because it is fun object oriented language. As soon as you start learning it you will be making windows, menus, buttons, and etc. Learning that first will help you decide if programming is really want you want to do for a career. Next build on your knowledge and move to C and C++ and make more complex programs.
Reply:If u will be majoring in Computer Science, you will learn C Language first.


After learning C Language (procedural language), your syllabus will make u learn C++ (Object-oriented Language).


Then, after these 2 languages Java comes into picture.


No doubt, Java is more in use than C or C++.


My Advice wud be : Learn C, then C++ and finally Java.
Reply:C++ is more like Java than C. the more "natural" progression to learn would be C, C++ then Java.


C++ program need help?

/***************************************...


* fuwen xu 05/11/07 switch and looping.cpp *


* This program compute the commissions for the real estate company *


* Input:choice,agent_id,rsp,csp,msp,yesno,... *


* Output:nr,nc, nm,mc,trc,tcc, *


************************************** HISTORY ****************************


* Who Date Description *


**************************************...


* Fuwen Xu 05/11/2007 calculate commissions *


**************************************...


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


using namespace std;





#define RCR 0.1 /*residential commission rate*/


#define CCR 0.2 /*commercial commission rate*/


#define MCR 0.15 /*multiunt dwelling commission rate*/





int main()


{


int id, /*five digit number ID*/


price, /*selling pricce*/


nr=0, /*number of residential commissions computed*/


nc=0, /*number of commerical commissions computed*/


nm=0, /*number of multiunit commissions computed*/


yesno; /* program loops when = 1*/


double trc=0.0 , /*total of residential commissions*/


tcc=0.0 , /*total of commerical commissions*/


tmc=0.0 ; /*total of multiunit dwelling commissions*/


char choice, /*choose the what category r, c, m*/


space = ' '; /*space*/





cout %26lt;%26lt; "\n\n\n\n";


cout %26lt;%26lt; "\n***************Fuwen Commission Computer******************\n";


cout %26lt;%26lt; "\nDo you have a commission to compute?(1 = yes, 0 = no)? ";


cin %26gt;%26gt; yesno;


while (yesno == 1)


{


cout %26lt;%26lt; "\nPlease enter the Agent ID: ";


cin %26gt;%26gt; id;


cout %26lt;%26lt; "\nPlease enter the category of property sold";


cout %26lt;%26lt; "\n(R = residential, C = commercial, M = multiunit): ";


cin %26gt;%26gt; choice;


switch(choice)


{


case 'r':


case 'R':


trc-=trc;


cout %26lt;%26lt;"Please enter the selling price: ";


cin %26gt;%26gt; price;


trc += (price*RCR);


nr += 1;


cout %26lt;%26lt;"\n\nThe commission for this sale for Agent "%26lt;%26lt;space%26lt;%26lt;id;


cout %26lt;%26lt;" is: "%26lt;%26lt;setw(2)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;trc;


break;


case 'c':


case 'C':


tcc-=tcc;


cout %26lt;%26lt;"Please enter the selling price: ";


cin %26gt;%26gt; price;


tcc += (price*CCR);


nc+=1;


cout %26lt;%26lt;"\n\nThe commission for this sale for Agent "%26lt;%26lt;space%26lt;%26lt;id;


cout %26lt;%26lt;" is: "%26lt;%26lt;setw(2)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;tcc;


break;


case 'M':


case 'm':


tmc-=tmc;


cout %26lt;%26lt;"Please enter the selling price: ";


cin %26gt;%26gt; price;


tmc += (price*MCR);


nm+=1;


cout %26lt;%26lt;"\n\nThe commission for this sale for Agent "%26lt;%26lt;space%26lt;%26lt;id;


cout %26lt;%26lt;" is: "%26lt;%26lt;setw(2)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;tmc;


break;


default:


cout %26lt;%26lt; "\nAn invalid value was entered.\n";


}


cout %26lt;%26lt; "\n\n";


cout %26lt;%26lt; "\nDo you have another commission to compute?(1 = yes,0 = no)? ";


cin %26gt;%26gt; yesno;


}


trc+=trc;


tcc+=tcc;


tmc+=tmc;


cout %26lt;%26lt; "\n\n********************End of Run Report************************";


cout %26lt;%26lt; "\n\nTotal number of Residential commissions computed = "%26lt;%26lt;nr;


cout %26lt;%26lt; "\nTotal number of Commercial commissions computed = "%26lt;%26lt;nc;


cout %26lt;%26lt; "\nTotal number of Multiunit commissions computed = "%26lt;%26lt;nm;


cout %26lt;%26lt; "\nTotal number of all commissions computed = "%26lt;%26lt;(nr+nc+nm);


cout %26lt;%26lt; "\n\nTotal amount of Redidential commissions computed = "%26lt;%26lt;setw(9)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;tr...


cout %26lt;%26lt; "\nTotal amount of Commercial commissions computed = " %26lt;%26lt;setw(9)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;tcc;


cout %26lt;%26lt; "\nTotal amount of Multiunit commissions computed = "%26lt;%26lt;setw(9)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;tm...


cout %26lt;%26lt; "\n\nTotal amount of all commissions computed = "%26lt;%26lt;" $ "%26lt;%26lt;setw(12)%26lt;%26lt;fixed%26lt;%26lt;setprecision(2)%26lt;%26lt;(tr...


cout %26lt;%26lt; "\n";


return 0;








}

C++ program need help?
Your code doesn't keep an accurate total count of sales. For example, for switch case r/R you have trc-=trc, basically setting trc = 0 EVERY TIME switch case r/R is run. So the count is essentially wiped out all the time and when you're done the count isn't correct.
Reply:BigRez,


who says u to "cut" and "paste".


if u know the answer then


just "select" and"copy" then "paste" to C++.





Sorry i can't anser to question b/c i am C student not C++.
Reply:Well, what's the problem?





(You're better off telling us the problem is than just posting the code. When we see the code, Y!Answers will truncate long lines so we can't just cut and paste it into our compilers.)
Reply:Err, whats your question?


How Much C# Does ASP.NET Development requires?

I believe ASP%26gt;NET comes with its own controls etc.. Now I read that C# is sometimes requires to write code that ASP.NET does not provide. My question is simple.:


I know that at this point C# is needed but how much C# should i know? The basics? I am sure that to develop ASP.NET you don't need to know as much C# than if you are a C# software developer.





Thank you.

How Much C# Does ASP.NET Development requires?
.NET (dot net) is a framework which is used, typically, for web development. To that end, you can choose a few different languages to code in. C# and ASP are two such languages. If you are writing a .NET application, you do not need any knowlege of C#. You may choose to write the application in another language if you'd like.
Reply:You will need C# as if you are a software developer because thats what a web developer is; a software developer.





In general how much C# you will need depends on what you want your application to accomplish.





With ASP.NET controls you might end up writing less code, however you you will still need to write C#.





You will not need to go and read an in-depth C# programming book. Just learn the C# as presented in an ASP.NET book for beginners as you go. Usually that suffices for a beginner.





Hope that helps.
Reply:ASP.net isn't a language on it's own. it's part of Microsofts dotnet framework. It supports C#, VB.Net, J# and maybe others. I'm using vb.net myself but c# can be more powerfull if you want to create usercontrols etc. But 99.9% you can stick with vb.net which is a neat language. You'll learn it within a few weeks, you can follow microsofts excellent video-tutorials to get you started
Reply:Boy... a question straight to my heart...





Having just been through this dilemma not more than a month ago, I can tell you that ASP.Net only requires C# (or any other language) if you want to actually do more things than you can get from drag/drop elements and setting properties. If you want any database interaction that isn't 100% canned, you NEED custom programming.





How much do you need? Well, that depends upon what you are doing. Simple processing of webforms to handle what the user inputs requires some or all of the fundamentals of the launguage: Types, Variables and Constants, Expressions, Statements, and Operators. If you want to do any database interaction that isn't canned, you need Classes and Objects, Preprocessor Directives, Arrays, Indexers, Collections, Strings and Regular Expressions.





The only thing you don't need that a desktop application developer does is a knowledge of Windows Forms and how to interact with them. But I find it does help to be at least familiar with the concepts.





Feel free to contact me if you need help. Also, here are a couple of good books for you to read...


C HD is slave to E HD If I rmv C wil E stil work.How do I fnd which Drv holds OS I wnt 2 use C drv 4 other use

Will the E drv default to C and relabel all files and folders C


What are my options

C HD is slave to E HD If I rmv C wil E stil work.How do I fnd which Drv holds OS I wnt 2 use C drv 4 other use
If you remove the C hard drive, it will relabel your other drives.





Your operating system is probably on C:. Look for the drive that has a "WINDOWS" or "WINNT" folder in the root (it's nearly always C:). You will probably have to install your operating system again.





If you are using IDE drives (they have the 2-3 inch wide flat cables), you may need to change the E: drive from "Slave" to "Master" to make it work. This may be done by changing the cable plugged into it, or it may be done by changing a jumper switch on the back of the drive itself, depending on how old your machine is.

nobile

C++ Classes?

I've programmed in Java, C#, and VB (6.0 and .NET) for years, so I understand the concepts of private, public, protected, and object oriented programming. Recently here in college, we've started learning C++. We're going a bit to slow to peak my interest so I decided to do a bit of studying on my own. I know C++ is object oriented, but I haven't found a good way to create classes in C++. If anybody could point me to a site with an example for creating constructors, destructors, and the methods in the class, or just give me an example of one, then I'd greatly appreciate it! Thanks.

C++ Classes?
I have listed a site in my source. You could always look ahead in the book and see what kind of examples they have in their.


What's wrong with my vb C program???

#include "stdAfx.h"


#include %26lt;stdlib.h%26gt;


#include %26lt;string.h%26gt;


#include %26lt;ctype.h%26gt;


#include %26lt;conio.h%26gt;


#include %26lt;windows.h%26gt;





int create();


void inputData();


void createFile();


int addRec();


void DisplayTrans();


int update();


void addFile();


void deleteRec();





void printfRecord();


int isFound(char *target,int cnt);


void deleteRec(char *target,int cnt);





void displayTitle();


void search(char[],int*,int*);


void displayRec();


void updateRec(int);


void searchUpdate();


void searchNdisplay();





struct


{


char transNum[5];


char studID[11];


char dateBorrowed[11];


}trHeaderRec,trHeaderTemp[4];








FILE *trHeaderFile;











int main (void)


{


int choice;





trHeaderFile = fopen("TRHEADER.DAT","r");





if((trHeaderFile = fopen("TRHEADER.DAT","r"))==NULL)


trHeaderFile = fopen("TRHEADER.DAT","w+");


printf("File could not be opened!");





else


{


switch(choice)


case 1: create();


break;


case 2: DisplayTrans();


break;


case 3: addRec();


break;


case 4: deleteRec();


break;


default:searchNdisplay;


break;


}





int create()


{


char response;





trHeaderFile = fopen("TRHEADER.DAT","rb");





if(trHeaderFile != NULL)


printf("FILE ALREADY EXISTS...\n");





do


{


fflush(stdin);


printf("Hit 'Y' to OVERWRITE, otherwise hit 'N'?\t");


scanf("%c",%26amp;response);


}while(toupper(response) != 'Y'%26amp;%26amp;toupper(response) != 'N');





if(toupper(response) == 'Y')


{





createFile();


fclose(trHeaderFile);


}





else


{


createFile();


fclose(trHeaderFile);


}








return 0;


}





void createFile()


{


char response;


trHeaderFile = fopen("TRHEADER.DAT", "wb");


do


{


inputData();


fwrite(%26amp;trHeaderRec, sizeof(trHeaderRec), 1, trHeaderFile);


do


{


printf("Hit 'Y' to ADD MORE, hit 'N' to save and exit....\t");


fflush(stdin);


scanf("%c", %26amp;response);





}while(toupper(response) != 'Y' %26amp;%26amp; toupper(response) != 'N');





}while(toupper(response) == 'Y');


}








void inputData()


{


system("cls");


printf("4-character Transaction Number: ");


scanf("%s", trHeaderRec.transNum);


printf("10-character Student I.D.: ");


scanf("%s", trHeaderRec.studID);


printf("10-character Date Borrowed[mm/dd/yyyy]: ");


scanf("%s", trHeaderRec.dateBorrowed);





}





//display





void DisplayTrans()


{





system("cls");





trHeaderFile=fopen("TRHEADER.dat","r")...


if((trHeaderFile= fopen("TRHEADER.dat","r"))==NULL)


{


printf("The file does not exist.");


}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec)...





if(feof(trHeaderFile))


printf("File is empty");











else





{








printf("\t\t\t ***Transaction Report***\n");


printf("\n%5s%s%8s%s%4s%s", "", "TransNum", "", "studID", "", "dateBorrowed", "");








}





do





{





printf("\n%7s%s%12s%s%8s%s", " ", trHeaderRec.transNum, "", trHeaderRec.studID, "", trHeaderRec.dateBorrowed, "");


fread(%26amp;trHeaderRec,sizeof(trHeaderRec),1...











}while(!feof(trHeaderFile));














}fclose(trHeaderFile);





}





//add

















int addRec()


{


char reply;





trHeaderFile=fopen("TRHEADER.DAT","wb"...





if(trHeaderFile!=NULL)


printf("THE FILE ALREADY EXISTS\n");





do


{


fflush(stdin);


printf("Overwrite[Y/N]?\n");


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(...





if(toupper(reply)=='Y')


{ addFile();


fclose(trHeaderFile);


}


else


{ addFile();


fclose(trHeaderFile);





}


return 0;


}








void addFile()


{


char reply;


trHeaderFile=fopen("TRHEADER.DAT","wb...


do


{


inputData();


fwrite(%26amp;trHeaderRec,sizeof(trHeaderR...


do


{


printf("Add more[Y/N]?:");


fflush(stdin);


scanf("%c",%26amp;reply);


}while(toupper(reply)!='Y'%26amp;%26amp;toupper(r...





}while(toupper(reply)=='Y');


}








//void deleteRec()





//{


//headerFile=fopen("TRHEADER.DAT","r"...


//if(headerFile==NULL)


// {





// printf("The file does not exist!\n");


// printf("Press any key to end!!");


// fflush(stdin);


// getch();


// }


// else


//{


//fread(%26amp;headerRec,sizeof(headerRec)...


//if(feof(headerFile))


// {


// printf("The file is empty");


// fflush(stdin);


// getch();


// }


// else


// searchNdisplay();


// }


// fclose(headerFile);





// return 0;


//}


void searchNdisplay()


{


char target[11],ans,ANS;








trHeaderFile=fopen("TRHEADER.DAT","r"...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{





strcpy(trHeaderTemp[cnt].studID,trHe...


strcpy(trHeaderTemp[cnt].transNum,tr...


strcpy(trHeaderTemp[cnt].dateBorrowe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


do


{


printf("Input studentID:");


fflush(stdin);


gets(target);





if(isFound(target,cnt))


{


printfRecord();


do


{


printf("Do you want to delete this record?(y/n): ");


fflush(stdin);


scanf("%c",%26amp;ans);


}while(ans!='y'%26amp;%26amp;ans!='Y'%26amp;%26amp;ans!='n'...





if(ans=='y'||ans=='Y')


{


deleteRec(target,cnt);


printf("\nThe record has been deleted\n");


}





do


{


printf("Do you want to search another record?(y/n): ");


fread(%26amp;trHeaderRec,sizeof(trHeader...


fflush(stdin);


scanf("%c",%26amp;ANS);


}while(ANS!='y'%26amp;%26amp;ANS!='Y'%26amp;%26amp;ANS!='n'...


}


else


printf("Record is not in the list!");





trHeaderFile=fopen("TRHEADER.DAT","...





int cnt=0,found=0;


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


while(!feof(trHeaderFile))


{


strcpy(trHeaderRec.studID,trHeaderTe...


strcpy(trHeaderRec.transNum,trHeader...


strcpy(trHeaderRec.dateBorrowed,trHe...


fread(%26amp;trHeaderRec,sizeof(trHeaderRe...


cnt++;


}


fclose(trHeaderFile);


}while(ANS=='y'||ANS=='Y');





fclose(trHeaderFile);


}


int isFound(char *target,int cnt)


{


int found;





for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


found=1;


}


else


fread(%26amp;trHeaderRec, sizeof(trHeaderRec),1,trHeaderFile);





}


return found;


}


void printfRecord()


{





printf("%s\t%s\t%s\t%s\t%s\t%s\t\n",t... trHeaderRec.dateBorrowed);


}


void deleteRec(char *target,int cnt)


{


int num=0;


for(int a=0;a%26lt;cnt;a++)


{


if(strcmp(trHeaderTemp[a].studID,tar...


{


for(int b=cnt;b%26gt;=num;b++)


{


trHeaderTemp[cnt]=trHeaderTemp[cnt...


}


break;


}


else


num++;


}


}





// update


int update()


{


trHeaderFile=fopen("TRHEADER.DAT","r")...





if(trHeaderFile==NULL)


{


printf("The file does no exist\n\n press any key to continue\n");


getch();





}


else


{


fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


if(!feof(trHeaderFile))


printf("file is empty...\n\n");


else


searchUpdate();


}


return 0;


}





void searchUpdate()


{


char answer,target[5];


int found,size,len;





displayTitle();





do{


do{


printf("record to be update\n");


printf("transaction code");


scanf("%s",target);


len=strlen(target);





}


while(len!=4);


search(target,%26amp;found,%26amp;size);


if(!found)


printf("the record does not exist");


else


{


displayRec();


do{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);





}


while(answer!='Y'%26amp;%26amp; answer!='N');





if(answer=='Y')


updateRec(size);





do


{


printf("update this record [Y/N]?");


fflush(stdin);


scanf("%c",%26amp;answer);


answer=toupper(answer);


}


while(answer!='Y'%26amp;%26amp; answer!='N');





}


}


while(answer=='Y');


}





void displayTitle()


{


printf("\n\n");


printf("USJR\n");


printf("\tlibrary");


printf("\trecords of books borrowed");





}





void search(char tar[],int*fnd,int*sz)


{


int cnt=0;





trHeaderFile=fopen("TRHEADER.DAT","r"...





fread(%26amp;trHeaderRec,sizeof(trHeaderRec...


*fnd=0;


*sz=0;





while(!feof(trHeaderFile)%26amp;%26amp;*fnd!=1)


{


if(tar==trHeaderRec.transNum)


*fnd=1;


else


{


cnt++;


fread(%26amp;trHeaderRec,sizeof(trHeaderR...





*sz=cnt*sizeof(trHeaderRec);


}


}


}


void displayRec(){


printf("transaction number: %s\n",trHeaderRec.transNum);


printf("studID: %s\n",trHeaderRec.studID);


printf("dateBorrowed: %s\n",trHeaderRec.dateBorrowed);


}





void updateRec(int size)


{


char reply;


int choice;





do{


clearScrn();





do{





printf("which field you want to update?\n");


scanf("%d",%26amp;choice);


}


while(choice%26lt;4);





switch (choice)


{


case 1:


printf("transaction #\n");


scanf("%s",trHeaderRec.transNum);


break;


case 2:


printf("dateBorrowed\n");


scanf("%s",trHeaderRec.dateBorrowed);


break;


case 3:


printf("studID\n");


scanf("%s",trHeaderRec.studID);


break;


default:printf("unexpected choice of field\n");


}


do{


printf("do you want to update another?/n");


fflush(stdin);


scanf("%c",%26amp;reply);


}


while(reply!='Y'%26amp;%26amp;reply!='N');


}


while(reply=='Y');





fseek(trHeaderFile,size,SEEK_SET);


fwrite(%26amp;trHeaderRec,sizeof(trHeaderRec),...


fclose(trHeaderFile);


}

What's wrong with my vb C program???
You're not asking for much are you.





NB: Part of your code gets cut off by Y!A then you paste it in, so you might have to rely on the compiler to tell you what's wrong
Reply:Can you add additional infos?? i don't want to read all of them.. When you compile it what does it say?? and what line??
Reply:Do you have a compiler error message; or was it producing an unexpected output? Please provide additional info
Reply:1. What is it supposed to do?


2. What does it do?


3. What errors do you get?


4. Where is the complete source?


C++ calculator program?

I made this c++ calculator program, but for some reason it only multiplies. How can this be fixed? Here's the Program:


#include %26lt;iostream%26gt;


using namespace std;





double operate (double x, double y)


{


return (x*y);


}





float operate (float m, float n)


{


return (m/n);


}





int operate (int a, int b)


{


return (a+b);


}





long operate (long c, long d)


{


return (c-d);


}


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


{


double x, y;


float m, n;


int a, b;


long c, d;


char operation;


cout %26lt;%26lt; "Choose operation" %26lt;%26lt;endl;


cout %26lt;%26lt; "1: *, 2:/, 3:+, 4: - "%26lt;%26lt;endl;


cin %26gt;%26gt; operation;





while (operation = 1)


{


cout %26lt;%26lt; "enter x:" %26lt;%26lt;endl;


cin %26gt;%26gt; x;


cout %26lt;%26lt; "enter y:" %26lt;%26lt;endl;


cin %26gt;%26gt; y;


cout %26lt;%26lt; operate (x,y) %26lt;%26lt; endl;


cout %26lt;%26lt; "Choose operation" %26lt;%26lt;endl;


cout %26lt;%26lt; "1: *, 2:/, 3:+, 4: - "%26lt;%26lt;endl;


cin %26gt;%26gt; operation;


}





while (operation = 2)

C++ calculator program?
This is the easiest mistake to make. while (operation = 1) is actually RESETTING operation to 1. You need to do (operation == 1) instead.





Even experienced developers make this typo. To prevent it, get in the habit of putting the const first. While (1 == operation). The compiler will prevent you from ever messing up again.





The second problem is that operation is a char, but you are comparing it to an int. The compiler doesn't complain, because under the covers a char is really an int of the ASCII value of the char. If you fix the = to ==, you will fall through. You need to write while ('1' == operation) or define operation as an int instead of a char.





Once you fix that, you should be good to go. There is no problem with ambiguity with the operate functions. Your overloads are fine.
Reply:try operator overloading. . .it might make the program a bit shorter. . .
Reply:All your functions are called "operate", which is confusing, rename them to something more meaningful "MyMultiply", "MyDivide" etc.





Also, your while loop is only spinning if "operation" is "1". So it needs to loop if "operation" is less than four.





You'll will also need some extra logic inside the loop to determine the correct function to call.
Reply:Okay, going to try and tackle a couple of your issues, some which have already been mentioned:





1. Your while loops are using assignment "=" instead of comparison.





2. It seems that you are attempting to do operator overloading. You will call the different "operate" functions based on what types you feed in. Since you are stuck in your first while loop, you are always feeding in doubles 'x' and 'y' and therefore will always call your operator that deals with doubles.





3. The general structure of your program is a bit odd. It seems that what you generally want to do is loop infinitely(hopefully this is what you meant to do). If that is the case, you need a single while loop. Your current setup would make it so that you could at best, do some number of multiplies, then some number of divisions, then some addition, and then some subtraction, but you could never do addition, then multiplication, etc. Use a case/switch statement if you are familiar with it. If you aren't, you can use if statements. Then main thing is just to have one overall loop.
Reply:Why are you using While? While is a loop.





Change the while to a an If statement. Or better yet change to a switch statement (If you covered switch statements in your class).





switch (operations)





case '1'


{


cout %26lt;%26lt; "enter x:" %26lt;%26lt;endl;


cin %26gt;%26gt; x;


cout %26lt;%26lt; "enter y:" %26lt;%26lt;endl;


cin %26gt;%26gt; y;


cout %26lt;%26lt; operate (x,y) %26lt;%26lt; endl;


cout %26lt;%26lt; "Choose operation" %26lt;%26lt;endl;


cout %26lt;%26lt; "1: *, 2:/, 3:+, 4: - "%26lt;%26lt;endl;


cin %26gt;%26gt; operation;


break;


}


case '2'


...
Reply:I think there are a couple of reasons that the program will only mutiply, first being that all of the methods are named "operate", so when the program calls "operate", it is always going to use the first one encountered, which happens to be the one that multiplies. I would stongly suggest changing to each method name to a unique name.


Now, about the logic.. this program could be greatly simplified by creating methods for the inputting and outputting of the numbers, as well as an "operation" method that could perform any one of the four operations, depending on what the user chooses. You could include the operations in a swtich statement, like so :





switch (operation)


1


multiply the nums


break


2


divide the nums


break


...





Code may be a little of (I'm not a C++ developer) but the concept is good. Try that out. Good luck :)
Reply:include the int main() function, write your user define functions after the int main, and give them defferent names. your program shall work if you like i could give you a full code.