I need some help correcting my code the description is in the page.

0 Bob huginstien · April 10, 2015
You’re working for a company that lays ceramic floor tile, and its employees need a program that estimates the number of boxes of tile for a job. A job is estimated by taking the dimensions of each room in feet and inches, and converting these dimensions into a multiple of the tile size (rounding up any partial multiple) before multiplying to get the number of tiles for the room. A box contains 20 tiles, so the total number needed should be divided by 20 and rounded up to get the number of boxes. The tiles are assumed to be square.

The program should initially prompt the user for the size of the tile in inches and the number of rooms to be covered with tile. It should then input the dimensions for each room and output the number of tiles needed for that room. After data for the last room is input, the program should output the total number of tiles needed, the number of boxes of tile needed, and how many extra tiles will be left over.






//***********************************//
// This program counts tiles //
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;
const int inch_to_foot = 12;
const int boxTiles= 20;

int calc_tiles(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room_length_inches,
 );


  int void display
  (
  int num_tiles,
  int num_boxes,
   int balance,
    );
    int calc_boxes(int number_of_tiles);

    int main()
    {int tilesize,numberofRooms,Roomcounter;
    int room_width_ft;
    int room_width_inches;
    int room_length_feet;
    int room length_inches;
    int tiles_room;
    int boxes;
    int extra;
    int totaltiles = 0;




         cout << "Enter number of rooms:";
         cin>> numberofRooms;
         if(numberofRooms<0 || numberofRooms>5)
          {
              cout<< "Invalid room count, range from 1-5.";
             return 1 ;

          }
        cout << "Enter the value for size of tile in inches:";
        cin >> tilesize;

         if (tilesize<1|| tilesize>12)
         {
             cout<< " Invalid tile size, please renter size 1-12:";
             return 1;
         }

     cout<< endl;


   for (Roomcounter = 0; Roomcounter < numberofRooms; Roomcounter++)
    {
    cout <<  "Enter the value for room width (feet and inches separated by a space: ";
    cin >>room_width_ft;
    cin >>room_width_inches;
    if(room_width_ft<5 || room_width_ft>30|| room_width_inches<1 || room_width_inches>12)
      {
          cout<< "Invalid entry, please enter 5-30 for feet and 1-12 for inches:";
          return 1 ;
      }

     cout<< "Enter the value for room length (feet and inches separated by a space: ";
     cin>>room_length_feet;
     cin>> room length_inches;

     if(room_length_feet<5 || room_length_feet> 30 || room_length_inches<1 || room_length_inches>12 )
     {
       cout<< "Invalid entry, please enter 5-30 for feet and 1-12 for inches:";
      return 1 ;

     }
    tiles_room = calc_tiles4room (tilesize, room_width_ft, room_width_inches,room_length_feet,room_length_inches);
    totaltiles += tiles_room;
   cout << "Room requires" << tiles_room << "tiles. \n \n";

    boxes = calc_boxes(totaltiles);
    extra = (boxes* boxTiles)-totaltiles;
    display(totaltiles,boxes, extra);
    return 0;
    }
    }
   int calc_tiles

(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room length_inches,
 )
 { int tiles = (ceil(((room_width_ft*inch_to_foot)+room_width_inches) / float (tilesize)))*(ceil(((room_length_feet*inch_to_foot)+room_length_inches)/float(tillesize)));
  return tiles;

 }
 int calc_boxes(int numberofTiles)
   {
       int boxes;
       boxes = ceil(float(numberofTiles)/Box_tiles);
       return boxes;
   }
    void display(int num_tiles, int num_boxes, int balance)
    {
        cout << "Total number of tiles required is: " << num_tiles<< "."<< endl;
        cout << "Total number of boxes needed is: " << num_boxes << "."<< endl;
        cout << "There will be" << balance << "balance tiles.";
    }

its not registering my function prototypes. 

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · April 10, 2015
In function/function prototype calc_tiles:
int calc_tiles(int tilesize,
int room_width_ft,
int room_width_inches,
int room_length_feet,
int room_length_inches,   /* extra comma at the end here */
);

In function prototype display:

int void display
(
int num_tiles,
int num_boxes,
int balance,   /* extra comma at the end here */
);
0 Bob huginstien · April 10, 2015
Thank you 


what about in this section?

int calc_tiles(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room_length_inches
 )
 { int tiles = (ceil(((room_width_ft*inch_to_foot)+room_width_inches) / float (tilesize)))*(ceil(((room_length_feet*inch_to_foot)+room_length_inches)/float(tillesize)));
  return tiles;

 }


i get an error here.
0 Bob huginstien · April 10, 2015
Thank you 


what about in this section?

int calc_tiles(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room_length_inches
 )
 { int tiles = (ceil(((room_width_ft*inch_to_foot)+room_width_inches) / float (tilesize)))*(ceil(((room_length_feet*inch_to_foot)+room_length_inches)/float(tillesize)));
  return tiles;

 }


i get an error here.
0 Bob huginstien · April 10, 2015
Also  in my for loop it wont let me enter in the room lengths and widths.
0 Bob huginstien · April 10, 2015
//***********************************//
// This program counts tiles //
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;
const int inch_to_foot = 12;
const int boxTiles= 20;

int calc_tiles(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room_length_inches
 );


   void display
  (
  int num_tiles,
  int num_boxes,
  int balance
  );

    int calc_boxes(int number_of_tiles);

    int main()
    {int tilesize,numberofRooms,Roomcounter;
    int room_width_ft;
    int room_width_inches;
    int room_length_feet;
    int room_length_inches;
    int tiles_room;
    int boxes;
    int extra;
    int totaltiles = 0;




         cout << "Enter number of rooms:";
         cin>> numberofRooms;
         if(numberofRooms <0 || numberofRooms>5)
          {
              cout<< "Invalid room count, range from 1-5.";


          }
        cout << "Enter the value for size of tile in inches:";
        cin >> tilesize;

         if (tilesize<1|| tilesize>12)
         {
             cout<< " Invalid tile size, please renter size 1-12:";

         }


     cout<< endl;


   for (Roomcounter = 0; Roomcounter < numberofRooms; Roomcounter++)

    {
    cout << "Enter the value for room width (feet and inches separated by a space: ";
    cin >>room_width_ft;
    cin >>room_width_inches;

    if(room_width_ft<5 || room_width_ft>30|| room_width_inches<1 || room_width_inches>12)
      {
          cout<< "Invalid entry, please enter 5-30 for feet and 1-12 for inches:";

      }

     cout<< "Enter the value for room length (feet and inches separated by a space: ";
     cin>> room_length_feet;
     cin>> room_length_inches;

     if(room_length_feet<5 || room_length_feet> 30 || room_length_inches<1 || room_length_inches>12 )
     {
       cout<< "Invalid entry, please enter 5-30 for feet and 1-12 for inches:";


     }
    tiles_room = calc_tiles(tilesize, room_width_ft, room_width_inches,room_length_feet,room_length_inches);
    totaltiles += tiles_room;
   cout << "Room requires" << tiles_room << "tiles. \n \n";

    boxes = calc_boxes(totaltiles);
    extra = (boxes* boxTiles)-totaltiles;
    display(totaltiles,boxes, extra);
    return 0;
    }


    }
int calc_tiles(int tilesize,
 int room_width_ft,
 int room_width_inches,
 int room_length_feet,
 int room_length_inches
 )
 { int tiles = (ceil(((room_width_ft*inch_to_foot)+room_width_inches) / float (tilesize)))*(ceil(((room_length_feet*inch_to_foot)+room_length_inches)/float(tilesize)));
  return tiles;

 }
 int calc_boxes(int numberofTiles)
   {
       int boxes;
       boxes = ceil(float(numberofTiles)/boxTiles);
       return boxes;
   }
    void display(int num_tiles, int num_boxes, int balance)
    {
        cout << "Total number of tiles required is: " << num_tiles<< "."<< endl;
        cout << "Total number of boxes needed is: " << num_boxes << "."<< endl;
        cout << "There will be" << balance << "balance tiles.";
    }
  • 1

C++

106,950 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator