# How do you round up?

 Giorgio M · January 31, 2015 I've tried everything possible and the final answer won't round up. This is what I have so far and this is what it is telling me to do."Enter pounds: 7Enter shillings: 17Enter pence: 9Result in Decimal pounds = £7.89In ASCII the '\x9c' represents the pound sign. Also, display the result with two decimal places (display £7.89, not £7.88xxxx) by using the fixed, showpoint and setprecision() manipulators"I got the code working perfectly, the one issue I am having is that I keep getting £7.88 not £7.89 I got it rounded to 2 decimal places at least. If anyone can help that would be highly appericated. Thank You-Giorgio``#include #include #include using namespace std;int main(){//Declare Variablesint Pounds;int Shillings; int Pence;string User_Answer;//Initialize VariablesPounds = 0;Shillings = 0;Pence = 0;User_Answer = "C";while ( User_Answer == "C" || User_Answer == "c" ){ cout << "Enter pounds     : "; cin >> Pounds; cout << "Enter shillings  : "; cin >> Shillings; cout << "Enter pence      : "; cin >> Pence; Pence = (((Shillings * 12) + Pence) * 100)/240; //If statement (Pence will not exceed 100) if (Pence >= 100){ //Calculating expressions Shillings = Pence % 100; Pounds = Pounds + ((Pence-Shillings) / 100); Pence = Shillings; } cout << "Decimal pounds   = \x9c" << fixed << setprecision(2) << Pounds << "." << Pence << endl; cout << "Press C to continue or E to exit.\t\t"; cin >> User_Answer; }system("pause");return 0;}``

## Replies

 Jay Deshaun · February 1, 2015 I found a way to round for you.Look at this: HereYour code with the round:``#include #include #include using namespace std;int main(){ //Declare Variables and Initialize Variables int Pounds = 0; int Shillings = 0;  int Pence = 0; string User_Answer = "C"; while ( User_Answer == "C" || User_Answer == "c" ){ cout << "Enter pounds     : "; cin >> Pounds; cout << "Enter shillings  : "; cin >> Shillings; cout << "Enter pence      : "; cin >> Pence; Pence = (((Shillings * 12) + Pence) * 100)/240; //If statement (Pence will not exceed 100) if (Pence >= 100){ //Calculating expressions Shillings = Pence % 100; Pounds = Pounds + ((Pence-Shillings) / 100); Pence = Shillings; } cout << "Decimal pounds   = \x9c" << fixed << setprecision(2) << Pounds << "." << round(Pence) << endl; cout << "Press C to continue or E to exit.\t\t"; cin >> User_Answer; } system("pause"); return 0;}`` Jay Deshaun · February 1, 2015 @KrootushasThanks for indicating that to me, I'm so use to Java. Mahmoud Abdel Ghani · February 1, 2015 ``This is what you want bro try it and enjoy!!!!void main(){// Declare Variablesint Pounds;int Shillings;int Pence;char User_Answer; //here you should declare a char because the user                      // will enter a character not string//Initialize VariablesPounds = 0;Shillings = 0;Pence = 0;User_Answer = 'C';while (User_Answer == 'C' || User_Answer == 'c')//here notice the ' 'from                       //" "because it makes difference with the loops{cout << "Enter pounds : ";cin >> Pounds;cout << "Enter shillings : ";cin >> Shillings;cout << "Enter pence : ";cin >> Pence;Pence = (((Shillings * 12) + Pence) * 100) / 240;//If statement (Pence will not exceed 100)if (Pence >= 100){//Calculating expressionsShillings = Pence % 100;Pounds = Pounds + ((Pence - Shillings) / 100);Pence = Shillings;}cout << "Decimal pounds = \x9c" << fixed<> User_Answer;}`` Giorgio M · February 1, 2015 Thank You all for the help I actually spent so many hours and found a solution. Now I got it working fine. If anyone wants to see the code lmk and I'll happily put it on here just for your curiousity!
• 1

## C++

107,324 followers