mercredi 13 février 2019

Issue with formatting

I can not get my even or odd column to format correctly with my headers. PLZ HELP

I have tried using setw to allign everything nothing will properly allign. I also keep getting 1 and zeros returned for my boolean, and need help removing them.

int a=0;
   double volume = 0.0;
   double area = 0.0;
   double volumeSF = 0.0;
   cout<<fixed<<setprecision(2);
   double totalArea = 0.0;
   double totalVolume = 0.0;
   int remainder = 0;
   string EO;
bool myFlag = true;
   cout<<setw(5)<<"Edge"<<setw(10)<<"Volume"<<setw(10)<<"Area"<<setw(15)<<"Volume so far"<<setw(15)<<"Even or Odd";
   for(a=1;a<=15;a++)
   {
     if(a==5)
     continue;
      if(a%2==0)
  {
  myFlag = true;
   cout<<"even number";
  }
  else
  {
  myFlag = false;
  cout<<"odd number";
  }
    volume = pow(a,3)/(6*sqrt(2));
     area = cbrt(3)*pow(a,2);
      volumeSF = volume +volumeSF;
      cout<<setw(5)<<a<<setw(5)<<volume<<setw(5)<<area<<setw(10)<<volumeSF<<setw(15)<<myFlag<<endl;
      totalArea = area +totalArea;
      totalVolume = volume +totalVolume;


   }

Aucun commentaire:

Enregistrer un commentaire