// 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
浙公网安备 33010602011771号