View Full Version: This is the first program I've made without copyin

C++ Learning Community > C++ Creations > This is the first program I've made without copyin


Title: This is the first program I've made without copyin
Description: or reference to my books


TheRealNapster - November 22, 2003 12:26 AM (GMT)
:D

TheRealNapster - November 4, 2003 12:32 PM (GMT)
ok, well it did have some problems at first that i got some help on, but i'm still excited about my first real program. the source code is below. it is a calculation program. you should try it out and PM me to tell me what you think! :)

CODE

#include <iostream.h>
double addNums(double, double);
double subNums(double, double);
double mulNums(double, double);
double divNums(double, double);
int main()
{
    for(;;)
    {
    char opSelect;
    double answer;
    int firstnum, secondnum;
    cout<<"Please choose an operation, or type 'Q' to leave the program. ";
    cin>>opSelect;
    switch(opSelect)
    {
          case '+':
               cout<<"You have chosen addition."
                       <<"\nNow, please enter two numbers that you want to add: "<<endl;
               cin>>firstnum>>secondnum;

               answer = addNums(firstnum, secondnum);
                         cout<<"\nThe answer to your addition problem is "<<answer<<endl;
                         continue;
                       
          case '-':
              cout<<"You have chosen subtraction."
                       <<"\nNow, please enter two numbers that you want to subtract: "<<endl;
               cin>>firstnum>>secondnum;

               answer = subNums(firstnum, secondnum);
                         cout<<"\nThe answer to your subtraction problem is "<<answer<<endl;
                         continue;
                       
          case '*':
             cout<<"You have chosen multiplication."
                       <<"\nNow, please enter two numbers that you want to be multiplied: "<<endl;
               cin>>firstnum>>secondnum;

               answer = mulNums(firstnum, secondnum);
                         cout<<"\nThe answer to your multiplication problem is "<<answer<<endl;
                        continue;
                       
          case '/':
              cout<<"You have chosen division."
                       <<"\nNow, please enter two numbers that you want to divide: "<<endl;
               cin>>firstnum>>secondnum;

               answer = divNums(firstnum, secondnum);
                         cout<<"\nThe answer to your division problem is "<<answer<<endl;
                         continue;
             
          case 'Q':
              cout<<"Thank you for using this program.  --Brought to you by Derek Barclay   c 2003";
                   system("pause");
                   goto lblQuitting;
               
          default:
              cout<<"You have entered an invalid operation!";
               continue;
           
    }
    }lblQuitting:;
       
return 0;
}
double addNums(double x, double y)
{
          double sum;

          sum = (x + y);
          return sum;
}
double subNums(double x, double y)
{
         double difference;

         difference = (x - y);
         return difference;
}
double mulNums(double x, double y)
{
         double product;

         product = (x * y);
         return product;
}
double divNums(double x, double y)
{
          double quotient;

          quotient = (x / y);
          return quotient;
}


ih8censorship - November 4, 2003 04:19 PM (GMT)
thats pretty good!however i would tell the user what all the commands were so they dont get invalid errors when they try to do something(not everyone can read source code...well everyone here should be able to but a general person might not be able to) did you have a lot of time de bugging it?

TheRealNapster - November 4, 2003 11:35 PM (GMT)
ok, ill do that

no, it only took me lot 30 minutes to get everythin strait

Dixon - November 6, 2003 02:26 PM (GMT)
Not how I would program it but looks nice.

TheRealNapster - November 9, 2003 12:42 AM (GMT)
What's wrong with the way I programmed it?

Dixon - November 9, 2003 01:40 AM (GMT)
I didn't look at it REAL close. But probaly nothing I am just saying that thats not the same way that I would make a program to do the samething. But I don't know if it realy matters and I am not very good with C++ yet and maybe your way is better (and maybe mine is) :)

Dragon - November 9, 2003 01:45 AM (GMT)
Dixon, people program in different styles. I'm sure my programming style is different from yours. That doesn't make my style better than yours, or yours better than mine. There is no standard C++ programming style.

TheRealNapster - November 9, 2003 02:01 AM (GMT)
Yah. lol :)

Dixon - November 10, 2003 04:53 PM (GMT)
QUOTE
Dixon, people program in different styles. I'm sure my programming style is different from yours. That doesn't make my style better than yours, or yours better than mine. There is no standard C++ programming style.

Yea Just what I meant by my last post! :angry:

TheRealNapster - November 21, 2003 07:35 PM (GMT)
Ok, I think it is unnecessary to get mad. I was just trying to explain how I think you are boasting about yourself, I'm sorry but that's what I got out of your posts....sorry

Dixon - November 21, 2003 08:35 PM (GMT)
I was not boasting. I really don't know much about C++. I was just stating a fact and that is not how I would have done it. I never even said that my way was better I just said that my way was different.

TheRealNapster - November 21, 2003 09:22 PM (GMT)
Ok, we had a misunderstanding. I thought, through your posts, that you were bad-mouthin my code or sumthin. No biggie. Thx for commenting on my code in the first place :)

Dixon - November 21, 2003 11:03 PM (GMT)
:)

inuyaga - November 28, 2003 07:53 PM (GMT)
-code is poetry it has rythems and rime and can describe to you you entire world in a single line or show you nothing in a thousand.

-there is no better show of a person than his/her code. For each it is unique because code essancalley is the person who wrote it. there mind inscribed upon the screen. and evreybodyes mind is unique.

--Though some better than others.

well to say one thing. I dont like your code :( . Thst sounds harsh though... <_< ...
let me put this a better way. When i look at your code i see some one who learned form a book. I dont see you i see the person who wrote that book. And i dont like him verey much. In my openion he is not a good coder. Unfortunitalley you learned from him. So there for neather are you. But that dosent mean you yourself are a bad coder. it means you where taught wrong. Which means you can learn the right way. I am a completley self taught programmer. I have never owned a programming book. Never checked one out ot the libray. All i did was look at code and figure it out. Now this may not work for you. I recomend though you go and eather find a programmer you can talk to of start a "good" relationship with one online. some one who will answer your questions no matter how stupid.

--I did this too.. Having ppl to ask whe your starting out is good. ppl seem to be a tad bit more flexiable than books..... <_< i guess books are pretty flexable though.

well on a lighter note. It is most exelent that you where able to code that on your own if you are new to c++. It means you are learning.

:lol:

Bob - November 29, 2003 12:02 AM (GMT)
for some reson my comp. doesn't like the
system("pause"); thing it calls it an error

QUOTE
-code is poetry it has rythems and rime and can describe to you you entire world in a single line or show you nothing in a thousand.

very nice were did you get it off of :lol:

QUOTE
i guess books are pretty flexable though.

unnless there hardbacked :lol:




* Hosted for free by InvisionFree