Rounding with Microsoft Visual Studio .NET 2003

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2005
Posts: 1
Reputation: Shun is an unknown quantity at this point 
Solved Threads: 0
Shun Shun is offline Offline
Newbie Poster

Rounding with Microsoft Visual Studio .NET 2003

 
0
  #1
Sep 21st, 2005
This is begining to bug me. I have googled it. I have searched this site and I still have not managed to get the rounding to work the way I want!

I have done the Math::Round() deal, I have tried System::Math::Round. I got desperate and looked to see what it would do depending on which ones were capitalized. All i get while capitalized is that they aren't a class/identifier. Undercase with the system::math::round approach I get a "fatal error c1001: internal compilier error" message.

The rounding thing ain't really needed for this assignment.. but it bugs me cause it looks really sloppy as is. I suppose posting the code would not hurt-

  1. // ex10.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int _tmain()
  9. {
  10. float a;
  11. float b;
  12. float c;
  13.  
  14. cout << "\nPlease enter number of pounds: ";
  15. cin >> a;
  16. cout << endl << "Please enter number of Shillings: ";
  17. cin >> b;
  18. cout << endl << "Finally, Please enter number of Pence: ";
  19. cin >> c;
  20. cout << "\nYou have entered \x9c" << a << "." << b << "."
  21. << c << endl;
  22. if (c>=12)
  23. {
  24. c -= 12;
  25. b++;
  26. }
  27. if (b>=20)
  28. {
  29. b -= 20;
  30. a++;
  31. }
  32. float d = (b*12 + c) / 240;
  33. System::Math::Round(d, 2);
  34. d = a + d;
  35. cout << "\n\n\nYou have \x9c"
  36. << d <<" pounds with the current system!" << endl
  37. << endl << endl << endl;
  38. system ("pause");
  39. return 0;
  40. }

I imagine I am just missing something extremely stupid. And I don't need to have it... but I just get hung up on things. Once I try something I hang on tooth and nail to I get it done.

Any help would be greatly appreciated(as i said I am probably just overlooking something considering the time I have spent looking this problem up).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 3060 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC