``````I cant get this to read these numbers correctly
11.95f, SQFT2 = 12.35f, SQFT3 = 13.28f, PI = 3.14159f,
when i run it , the answer comes out to be a whole number 11.``````

i also need help on the do while loop i almost got it but i ended up being lost

``````#include <iostream>
using namespace std;
int main()
{``````
``````char symb;
int sqft, SQFT1 = 11.95f, SQFT2 = 12.35f, SQFT3 = 13.28f, PI = 3.14159f, radius, length, width, base, height, area;``````
``````cout << " What type of area are you carpeting? \n";
cout << " Choose from the following:\n" << endl;
cout << " A()Circle " << endl;
cout << " B() Rectangle " << endl;
cout << " C() Right Triangle \n" << endl;
cout << "Press the return key when finished.\n" << endl;
cin >> symb;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);``````
``````do
{
cout << endl;``````
``````switch (symb)
{
case 'A':;
case 'a':;
cout << " You have choosen A. circle.";
break;
case 'B':;
case 'b':;
cout << " You have choosen B. rectangle." ;
area = length * width;
break;
case 'C':;
case 'c':;
cout << "You have choosen C. right triangle.";
area = 2/(base * height);
break;
case 'D':;
case 'd':;
cout << "You have choose D. which means you want to quit.";
area= 0;
break;``````

}

``````cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(4);
{
if (( sqft >= 150))
cout << " It will cost you " << SQFT1 << " per square foot\n ";
else if ( sqft <= 150 && sqft >= 75 )
cout << " It will cost you " << SQFT2 << " per squrar foot\n";
else if ( sqft < 75 )
cout << " It will cost you " << SQFT3 << " per square foot \n";``````

}

``}while (``

return 0;
}

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by WaltP

The only things `int` can hold are whole numbers. Any precision you assign to an integer will be truncated.

Edited by Narue: n/a

From no Code tags to Code tags every 3 lines. :icon_rolleyes: C'mon, put CODE tags around your code. Don't add them just to add them. Don't add them around questions. Only the code -- all of it. Once -- unless you have two distinct pieces of code (two files, two functions that aren't connected)