Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Page 2 of 3 FirstFirst 123 LastLast
Results 9 to 16 of 20
  1. #9
    naodx is offline Registered User
    Join Date
    Jan 2003
    Location
    Omaha, Ne
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mkwan,

    I'm not sure what you are talking about there, please give more info. Are you talking about the division function????

  2. #10
    naodx is offline Registered User
    Join Date
    Jan 2003
    Location
    Omaha, Ne
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    trip,

    my first program was some variant of hello, but it was using the old apple II basic back in junior high, if that tells you anything.

    I did do the currency conversion program, but it wasn't until I hit college and it was in c++ (ok so I had a few years between high school and college, but at least I finally made it)

  3. #11
    mkwan's Avatar
    mkwan is offline Tech
    Join Date
    Aug 2001
    Location
    Canada
    Posts
    240
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there is no check if a user inputs letters instead of numbers
    mkwan

    UNIX was created in the late 1960s, in an effort to provide a multiuser, multitasking system for use by programmers. The philosophy behind the design of UNIX was to provide simple, yet powerful utilities that could be pieced together in a flexible manner to perform a wide variety of tasks.

  4. #12
    naodx is offline Registered User
    Join Date
    Jan 2003
    Location
    Omaha, Ne
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mkwan,

    very true, but you usually don't do to much for error checking in a beginning level program. That comes later after you master the basics.

  5. #13
    Arden's Avatar
    Arden is offline Where mah "any" keys at?
    Join Date
    Dec 2002
    Location
    Spokane, WA
    Posts
    7,754
    Thanks
    0
    Thanked 1 Time in 1 Post
    I would say, whenever you want to show off code like this, use the [ code ] [ /code ] tag in vB... put your code between these tags (without the spaces), and it will format correctly.
    Systems:
    2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 320 GB hard drive, runs 10.6.8
    1.6 GHz iMac G5, 1.5 GB RAM, 120 GB hard drive, runs 10.4.11 (out of commission)
    iPhone 4, 16 GB, iOS 4.3.5

  6. #14
    bkaron's Avatar
    bkaron is offline Yep, That's Me!
    Join Date
    Oct 2003
    Location
    Florida
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like this: (btw, thanks for the code. You really know your stuff)

    Code:
    #include <iostream>
     
     using namespace std;
     
     void add( float, float );
     void sub( float, float );
     void mult( float, float );
     void divd( float, float );
     
     int main()
     {
         cout << "Input two numbers and an operator ";
         float a;
         float b;
         char oper;
         cin >> a >> b >> oper;
     
         switch( oper )
         {
             case '+':
                 add( a, b );
                 break;
             case '-':
                 sub( a, b );
                 break;
             case '*':
                 mult( a, b );
                 break;
             case '/':
                 divd( a, b );
                 break;
             default:
                 break;
         }
     
         return( 0 );
     }
     
     void add( float x, float y )
     {
         cout << "Answer: " << x + y << endl;
     }
     
     void sub( float x, float y )
     {
         cout << "Answer: " << x - y << endl;
     }
     
     void mult( float x, float y )
     {
         cout << "Answer: " << x * y << endl;
     }
     
     void divd( float x, float y )
     {
         if( y == 0 )
         {
             cout << "Can't divide by zero, setting denominator to 1" << endl;
             y = 0;
         }
         cout << "Answer: " << x / y << endl;
     }
    PowerBook G4
    - 867MHz G4, 640MB, 80GB HD, 80GB EHD, SuperDrive, Airport, Mac OS X 10.4.8

  7. #15
    bkaron's Avatar
    bkaron is offline Yep, That's Me!
    Join Date
    Oct 2003
    Location
    Florida
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there a way I can edit the code si I can type in 5+5 insted of 5 5+
    PowerBook G4
    - 867MHz G4, 640MB, 80GB HD, 80GB EHD, SuperDrive, Airport, Mac OS X 10.4.8

  8. #16
    naodx is offline Registered User
    Join Date
    Jan 2003
    Location
    Omaha, Ne
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just change your cin statement:

    cin >> a >> oper >> b;

    that will do it

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. MAC OS X 'Mail' program
    By droliff in forum Mac OS X System & Mac Software
    Replies: 8
    Last Post: March 22nd, 2003, 07:33 AM
  2. Power Mac G4 Power Supply Exchange Program
    By bobw in forum Hardware & Peripherals
    Replies: 3
    Last Post: February 22nd, 2003, 02:17 AM
  3. How to compile stuff
    By fintler in forum Unix & X11
    Replies: 1
    Last Post: August 28th, 2002, 07:57 AM
  4. Anybody ever program a Classic app?
    By konan in forum Mac Classic System & Software
    Replies: 0
    Last Post: July 12th, 2002, 11:41 AM
  5. iTunes: the program formerly known as cool
    By Gregita in forum Opinions, & Open Letters
    Replies: 15
    Last Post: June 24th, 2002, 11:32 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •