944,198 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3961
  • C++ RSS
Sep 21st, 2005
0

Rounding with Microsoft Visual Studio .NET 2003

Expand Post »
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-

C++ Syntax (Toggle Plain Text)
  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).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Shun is offline Offline
1 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: structs vs classes?
Next Thread in C++ Forum Timeline: Program keeps crashing...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC