Thread: Programming Rounding Numbers

  1. #16
    Registered User
    Join Date
    Oct 2005
    Posts
    30
    I got what you meant, but still takes time to give an answer, I dont know now what is the problem but I have one solution to the problem. Thank you.

    Code:
    #include<iostream>
    using namespace std;
    
    #include<cmath>
    
    double roundtohundreths (double);
    int main()
    {
      char t = 'Y';
      double x;
      while( t != 'N' && t != 'n' )
      {
        if ( t == 'Y' || t == 'y' )
        {
          cout << "Enter number: ";
          cin >> x;
          while( char() != '\n' );
          cout << "Original value is: " << x << endl;
          cout << "Rounded number is: " << roundtohundreths( x ) << endl;
        }
        cout << "Type Y for entering a number ( N to end ): ";        
        cin >> t;
        char t += t = 'Y' // im not sure whether to add this to
                                           // give an immediate answer
      }
      return 0;
    }
    double roundtohundreths (double a)
    {
      double roundto = floor( a * 100 + .5 ) / 100;
      return roundto;
    }
    Last edited by mikeprogram; 10-30-2005 at 12:13 AM.

  2. #17
    Registered User
    Join Date
    Oct 2005
    Posts
    30
    SlyMaelstrom and Xipher:

    Problem solved thanks to your wonderful help. You made me challenge to the limit. I read your comments three or four times before realizing my mistake, but sincerely thank you to both of you. Your excellent programmers. Enjoy the extra hour from the DST time.

    Good night,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  2. Newbie question: rounding numbers
    By cantore in forum C Programming
    Replies: 10
    Last Post: 02-04-2006, 03:24 PM
  3. (C++) How would you go about rounding numbers?
    By jeffcoulter in forum C++ Programming
    Replies: 5
    Last Post: 09-19-2005, 07:47 AM
  4. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  5. Rounding Numbers accurately
    By crystaldawn68 in forum C++ Programming
    Replies: 5
    Last Post: 10-06-2001, 02:23 PM