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.";
           area = PI * (radius * radius);
            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;
}

Recommended Answers

All 2 Replies

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

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.