Why it doesnt put the total? (8.9e+002)

My output is like:

___________________________________________________

Total (USD 51.36)...........................17
Total (PHP).................................8.9e+002
___________________________________________________
CASH PESO...................................1e+003
CHANGE (PHP)................................1.1e+002
___________________________________________________


(Code: im doing the outfile version)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  ichi=q1*lays;
			nii=q2*luxury;
			san=q3*marshies;
			shi=q4*pocky;
			go=q5*clover;
			roku=q6*strawberry;
			nana=q7*toblerone;
			hachi=q8*nestle;
			kyuu=q9*nutella;
			ju=q10*yankee;
			rout << endl;
			totalll=ichi+nii+san+shi+go+roku+nana+hachi+kyuu+ju;
			php=(totalll*51.36);
			rout << "Total (USD 51.36)..........................." << setprecision(2) << totalll << endl;
			rout << "Total (PHP)................................." << php << endl;
			
			rout << "___________________________________________________" << endl;
			
			rout << "CASH PESO..................................." << cash << endl;
			rout << "CHANGE (PHP)................................" << change << endl;
setprecision(2)

What are you actually trying to do with this? Do you mean that you want the output to two decimal places?

i.e. something like "89.13" , rather than 8.9e+02

Here's some example code for that:
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	double totalll = 12.3456;
	cout << std::setprecision(2) << std::fixed << totalll << endl;
	return 0;
}



For the future, naming your variables after numbers (ichi, nii, san, etc.) is a bad idea. Anyone maintaining your code in the future will like meaningful names.
Last edited on
thanks to you! :>
Topic archived. No new replies allowed.