Hello !
I have a script, that i m running on visual C++ compiler everything is alright with it, working properly but in the result, I can see on one digit after decimal, not 2, i wanna display two digit i.e 31.02 ;
Code is;
# include <iostream.h>
# include <string.h>
# include <math.h>
# include <conio.h>
# include <stdlib.h>
//using std::string;
int main()
{
char Continue;
do
{
system("cls");
float hval,istval,isp,ival,gtot;
int a=1;
float isTotval=0.00;
cout<<"How many sales items do you have? : ";
cin>>hval;
for (int i=0;i<hval;i++)
{
cout<<"Enter in the value of sale item "<<a<<" : $";
cin>>ival;
a=a+1;
isTotval=isTotval+ival;
}
cout <<"\n";
cout <<"\n";
cout <<"\n";
cout <<"Enter in the sales tax percentage <Enter 10 for 10%>: ";
cin>>istval;
isp=(istval*10/100)*hval;
gtot = isTotval+isp;
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"********************************************************"<<endl;
cout<<"*************** S A L E S R E C E I P T ****************"<<endl;
cout<<"********************************************************"<<endl;
cout<<"** **"<<endl;
cout<<"** **"<<endl;
cout<<"** **"<<endl;
cout<<"**"<<" Total Sales $ "<<isTotval<<" **"<<endl;
cout<<"**"<<" Sales tax $ "<<isp<<" **"<<endl;
cout<<"**"<<" ---------------- **"<<endl;
cout<<"**"<<" Grand Total $ "<<gtot<<" **"<<endl;
cout<<"** **"<<endl;
cout<<"** **"<<endl;
cout<<"********************************************************"<<endl;
cout<<"\n";
cout<<"\n";
cout <<"\n" << " Do you wants to run this program again? (Y/N):";
cin >> Continue;
}
while (Continue=='Y' || Continue=='y');
}