Ok I have everything coded out, but my rounding still doesn't work. According to the book (and the professor follows the book to the letter so if I don't do it like this thats about 50% off my grade) I'm supposed to convert a float number to integer and back to float to round, but common sense, as well as what I see after compile, tells me that just completely destroys the decimals. Heres the code. Anyone got any clue how to do this?
Code:
// Program by Aaron Friedley
// October 12, 2003
// Program rounds input then finds ceiling and floor
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
int main (void)
{
// Prototypes
float round (void);
void ceilingfloor (float);
// Declarations
float num1;
// Calls
num1 = round ( );
ceilingfloor (num1);
return 0; // Terminate main
}
// *** round function ***
float round (void)
{
// Declarations
float num1;
int num2;
float num3;
cout << "Program by Aaron Friedley MWF 10:00\n\n"
<< "Input number: ";
cin >> num1;
// Declarations
num2 = num1;
num3 = num2;
cout << setiosflags(ios::fixed) << setiosflags(ios::showpoint)
<< setprecision(2) << "Rounded: " << num3;
return num3; // Terminate round
}
// *** ceilingfloor function ***
void ceilingfloor (float num1)
{
cout << "\nCeiling: " << ceil (num1)
<< "\nFloor: " << floor (num1) << "\n";
return; // Terminate ceilingfloor
}