// roundNumber.cpp : Defines the entry point for the console application.
  //

  #include "stdafx.h"
  #include <iostream>
  #include <cmath>
  using namespace std ;

  int roundNumber(double number) ;

  int main(int argc, char* argv[])
  {
   double doubleValue ;
   char ans ;

   do{
    cout <<"Enter a double value: " ;
    cin >> doubleValue ;
    cout <<"Rounded that number is " 
           <<roundNumber(doubleValue) <<endl ;
    

   cout <<"Again?(y/n): " ;
    cin >>ans ;
   }while(ans == 'Y' || ans =='y' ) ;

   cout <<"End of testing.\n" ;

   return 0 ;
  }

  int roundNumber(double number){
     return static_cast<int>(floor(number + 0.5) ) ;
  }

 

 

 

 

 

 

 

 

 posted on 2012-04-12 20:34  飞翔@骑士  阅读(132)  评论(0)    收藏  举报