User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,372 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,112 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1359 | Replies: 9 | Solved
Reply
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Troubleshooting Help with job estimate programs

  #1  
Oct 15th, 2006
Here is my problem
I am trying to write a program that will estimate the number of boxes of tile needed for a job. A job is estimated by taking the dimensions of each room in feet and inches and converting these 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 should have 20 tiles, so I need to divide the total number needed by 20 and rounded up to get the number of boxes (they are square). Here is what I have so far:


#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
usingnamespace std;
// Function prototypes
void PrintHeading();
void DetermineTileno(float, float, int, int, float&);
void PrintResults( float, float, int, int, float);
int main()
{
// Input Variables
float roomNumber;
float tileSize;
int roomLength;
int roomWidth;
float tileNo;

PrintHeading();

// Prompt for and read Room Number
cout << "Input the total number of rooms to be tiled: " << endl;
cin >> roomNumber;
// the tile size is the same for all rooms 
// Prompt for and read tile size, room width, room length.
cout << "Input the size of tile in inches:" << endl;
cin >> tileSize;
// Loop calculating room number
while (roomNumber >= 1)
{
}
struct _roomdim;
{
int feet, inches;
roomLength, roomWidth;

}
cout << "Input the width of room (feet and inches, seperated by "
<< "a space):" << endl;
cin >> roomWidth.feet >> roomWidth.inches;
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
cin >> roomLength.feet >> roomLength.inches;
 
DetermineTileno(roomNumber, tileSize, roomLength, roomWidth, 
tileNo);
PrintResults( roomNumber, tileSize, roomLength, roomWidth, 
tileNo);



 

{
// local variables
float roomSize; 
int tileCoverage;

roomSize = roomLength * roomWidth;
tileCoverage = tileSize * 20;
tileNo = ((roomSize)/(tileCoverage));
}
// dataOut.close();
cin.get();
cin.get();
return 0;
}
 

I get many errors when trying to compile this, and I also need to know what I can do to get it to give me a correct output of tiles needed. I am so confused on this!! Thanks in advance for any help you guys/gals can offer!

Emily
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Location: Australia,Sydney
Posts: 63
Reputation: rowly is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
rowly's Avatar
rowly rowly is offline Offline
Junior Poster in Training

Re: Help with job estimate programs

  #2  
Oct 15th, 2006
Hello, I couldnt get wt u r trying to do !
but i can tell that ya have problem with structers and functions...
anyways i wrote a hard coded program for you(probably its not what you trying to prove !)...try to use some functions!
cheers !
#include<iostream>
usingnamespace std;
struct _roomdim
{
int feet, inches;
} roomLength, roomWidth;
int main()
{
float roomNumber;
float tileSize;
cout << "\nInput the total number of rooms to be tiled: " << endl;
cin >> roomNumber;
cout <<"\nroomNumbeR:"<<roomNumber;
cout << "\nInput the size of tile in inches:" << endl;
cin >> tileSize;
cout <<"\ntileSize:"<<tileSize;
cout <<"\nInput the width of room (feet and inches, seperated by "
<< "a space):" << endl;
cin >> roomWidth.feet >> roomWidth.inches;
cout<<"\nroomWidth.feet:"<<roomWidth.feet<<"roomWidth.inches:"<<roomWidth.inches<<endl;
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
cin >> roomLength.feet >> roomLength.inches;
cout<<"\nroomLength.feet:"<<roomLength.feet<<"roomLength.inches:"<<roomLength.inches<<endl;
int roomWidthT=roomWidth.feet * roomWidth.inches;
cout <<"\nroomWidthT:"<<roomWidthT<<endl;
int roomLengthT=roomLength.feet * roomLength.inches;
cout <<"\nroomLengthT:"<<roomLengthT<<endl;
float roomSize=roomWidthT*roomLengthT;
cout<<"\nroomSize:"<<roomSize<<endl;
int tileCoverage =tileSize * 20;
cout<<"\nTileCoverage:"<<tileCoverage<<endl;
float tileNo = ((roomSize)/(tileCoverage));
cout<<"\nTileNumber:"<<tileNo<<endl;
cout<<"total number of tiles for all rooms"<<tileNo*roomNumber<<endl;
return 0;
}
DarkCoder+
Reply With Quote  
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Re: Help with job estimate programs

  #3  
Oct 15th, 2006
#include<iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
usingnamespace std;
struct _roomdim
{
int feet, inches;
} roomLength, roomWidth;
int main()
{
// input variables
float roomNumber;
float tileSize;

cout << "\nInput the total number of rooms to be tiled: " << endl;
cin >> roomNumber;
cout << "\nInput the size of tile in inches:" << endl;
cin >> tileSize;
cout <<"\ntileSize:"<<tileSize;
cout <<"\nInput the width of room (feet and inches, seperated by "
<< "a space):" << endl;
cin >> roomWidth.feet >> roomWidth.inches;
cout<<"\nroomWidth.feet:"<<roomWidth.feet<<"roomWidth.inches:"<<roomWidth.inches<<endl;
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
cin >> roomLength.feet >> roomLength.inches;
cout<<"\nroomLength.feet:"<<roomLength.feet<<"roomLength.inches:"<<roomLength.inches<<endl;
int roomWidthT = ((roomWidth.feet) * (roomWidth.inches));
cout <<"\nroomWidthT:"<<roomWidthT<<endl;
int roomLengthT = ((roomLength.feet) * (roomLength.inches));
cout <<"\nroomLengthT:"<<roomLengthT<<endl;
float roomSize = ((roomWidthT)*(roomLengthT));
cout<<"\nroomSize:"<<roomSize<<endl;
int tileCoverage = ((tileSize) * (20));
cout<<"\nTileCoverage:"<<tileCoverage<<endl;
float tileNo = ((roomSize)/(tileCoverage));
cout<<"\nTileNumber:"<<tileNo<<endl;
cout<<"total number of tiles for all rooms"<< ((tileNo)*(roomNumber))<<endl;

cin.get();
cin.get();
return 0;


Here are the hints I was given
This problem also requires you to have a good understanding of data types and the capabilities and limitations of int and float variables. In my discussion of this algorithm the use of the word "get" is the equivalent of the "cin".
Get the number of rooms.
Get the tile size in inches. We are given that the tile is a square, thus the length and width of the tile are the same.
Start of main loop
The number of rooms is the control variable for your main logic loop. You will repeat this logic for each room and exit the loop only when the necessary information has been determined for all rooms.
Room logic
Get the width and length of the room in feet and inches.
The smallest unit of measurement is the inch. Therefore, you calculate the number of inches for the width dimension and the number of inches for the length dimension.
Given this, you determine the number of tiles it will take for each dimension. You must take into account the affects of fractional tiles and roundup to determine the number of "whole" tiles. For example, if the tile size is 12 inches and the room width is 10 feet and 4 inches, the width in inches is 124 inches. Thus the number of tile to go across the width is 10.333 or 11 tiles.
You do the same for the length dimension. The number of tiles required for the room is simply the number of tiles in the length dimension times the number of tiles in the width dimension. (Remember the formula for the area of a rectangle?)
You repeat the above for each room, accumulating the total number of tiles required room by room.
End of main loop.
You now know the total number of tiles required and you must now determine the number of boxes of tiles required. You are given that there are 20 tiles per box. You can not have a fractional number of boxes. Once you determine the number of boxes, the extra tiles should be very easy to calculate.

Thanks for the help!!

Emily
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Help with job estimate programs

  #4  
Oct 15th, 2006
It would really your problem if you could create different functions for different tasks like: 1. Accepting the data 2. Performing the conversions 3. Performing the calculations for the number of tiles. If classes have been introduced in your course you can try creating a class "Room" which will pack all the data and functions in a single abstraction. Incorporate the followign changes and repost. It will also help you get good grades if you perform the task using functions.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Re: Help with job estimate programs

  #5  
Oct 15th, 2006
#include<iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
usingnamespace std;
struct _roomdim
{
int feet, inches;
} roomLength, roomWidth;
int main()
{
// input variables
float roomNumber;
float tileSize;
 
// Input Number of Rooms
cout << "\nInput the total number of rooms to be tiled: " << endl;
cin >> roomNumber;
 
//Input Tile Size
cout << "\nInput the size of tile in inches:" << endl;
cin >> tileSize;
cout <<"\ntileSize:"<<tileSize;
 
// Input Width of room
cout <<"\nInput the width of room (feet and inches, seperated by "
<< "a space):" << endl;
cin >> roomWidth.feet >> roomWidth.inches;
cout<<"\nroomWidth.feet:"<<roomWidth.feet<<"roomWidth.inches:"<<roomWidth.inches<<endl;
 
// check for errors
if (roomWidth.inches > 11)
cout <<"please use correct inches if over 11 inches make it foot." << endl;
cout <<"Input the width of room (feet and inches, seperated by "
<< "a space):" << endl;
 
// Input Length of room 
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
cin >> roomLength.feet >> roomLength.inches;
cout<<"\nroomLength.feet:"<<roomLength.feet<<"roomLength.inches:"<<roomLength.inches<<endl;
 
// Check for errors
if (roomLength.inches > 11)
cout << " please use correct inches if over 11 inches make it a foot." << endl;
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
 
 
 
// Varibles for Room Tile coverage and Length/Width
int roomWidthT = ((roomWidth.feet) * (roomLength.feet));
cout <<"\nroomWidthT:"<<roomWidthT<<endl;
int roomLengthT = ((roomLength.inches) * (roomWidth.inches));
cout <<"\nroomLengthT:"<<roomLengthT<<endl;
float roomSize = ((roomWidthT)+ (roomLengthT));
cout<<"\nroomSize:"<<roomSize<<endl;
int tileCoverage = ((tileSize) * (20));
cout<<"\nTileCoverage:"<<tileCoverage<<endl;
float tileNo = ((tileCoverage)/(roomSize));
cout<<"\nTileNumber:"<<tileNo<<endl;
cout<<"total number of tile boxes for all rooms "<< ((tileNo)*(roomNumber))<<endl;
 
 
cin.get();
cin.get();
return 0;
 
}

Here is what I have revampped so far, I think it for the most part works. But I can't figure out how to get my loop back in there for room numbers greater than 1 when I put it in it screws the code up. Thanks in Advance for advice on where to put my roomNumber Loop!
Last edited by Eadams20 : Oct 15th, 2006 at 12:35 pm.
Reply With Quote  
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Re: Help with job estimate programs

  #6  
Oct 15th, 2006
 
#include<iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
usingnamespace std;
struct _roomdim
{
int feet, inches;
} roomLength, roomWidth;
int main()
{
// input variables
float roomNumber;
float tileSize;

// Input Number of Rooms
cout << "\nInput the total number of rooms to be tiled: " << endl;
cin >> roomNumber;

//Input Tile Size
cout << "\nInput the size of tile in inches:" << endl;
cin >> tileSize;
cout <<"\ntileSize:"<<tileSize;

// Input Width of room
cout <<"\nInput the width of room (feet and inches, seperated by "
<< "a space):" << endl;
cin >> roomWidth.feet >> roomWidth.inches;
cout<<"\nroomWidth.feet:"<<roomWidth.feet<<"roomWidth.inches:"<<roomWidth.inches<<endl;

// check for errors
if (roomWidth.inches > 11)
cout <<"please use correct inches if over 11 inches make it foot." << endl;
cout <<"Input the width of room (feet and inches, seperated by "
<< "a space):" << endl;

// Input Length of room 
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;
cin >> roomLength.feet >> roomLength.inches;
cout<<"\nroomLength.feet:"<<roomLength.feet<<"roomLength.inches:"<<roomLength.inches<<endl;

// Check for errors
if (roomLength.inches > 11)
cout << " please use correct inches if over 11 inches make it a foot." << endl;
cout << "Input the length of room (feet and inches, seperated"
<< " by a space):" << endl;



// Varibles for Room Tile coverage and Length/Width
int roomWidthT = (((roomWidth.feet) * 12) + (roomWidth.inches));
cout <<"\nroomWidthT:"<<roomWidthT<<endl;
int tileWidth = ((roomWidthT / 12));
cout <<"\ntileWidth:"<<tileWidth<<endl;
int roomLengthT = (((roomLength.feet) * 12) + (roomLength.inches));
cout <<"\nroomLengthT:"<<roomLengthT<<endl;
int tileLength = ((roomLengthT / 12));
cout <<"\ntileLength:"<<tileLength<<endl;

float roomSize = ((roomWidthT)+ (roomLengthT));
cout<<"\nroomSize:"<<roomSize<<endl;
float tileNo = (((tileWidth) * (tileLength)));
cout<<"\nTileNumber:"<<tileNo<<endl;
cout<<"total number of tile boxes for all rooms "<< ((tileNo)/(20))<<endl;
 
 
cin.get();
cin.get();
return 0;
 
}

Okay it works mathmatically, but I can't loop it to do more than one room.. where do I stick my loop in. I have tried everywhere and it give me errors. I need it to loop for number of rooms>1
Last edited by ~s.o.s~ : Oct 15th, 2006 at 1:16 pm.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Help with job estimate programs

  #7  
Oct 15th, 2006
Think about it logically, where do you need to keep the loop. It should be obvio after the variables required throughout the prog have been entered by the user. So the loop should logically be placed before the block when you start accepting theroom specs from the user. Hence place the loop after you ask the number of rooms and the tile size from the user.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Re: Help with job estimate programs

  #8  
Oct 15th, 2006
// Input Number of Rooms
cout << "\nInput the total number of rooms to be tiled: " << endl;
cin >> roomNumber;

//Input Tile Size
cout << "\nInput the size of tile in inches:" << endl;
cin >> tileSize;
cout <<"\ntileSize:"<<tileSize;
while (roomNumber);
{ if (roomNumber >1);
}

If i put it in like this my program stops running right there. I guess I am over thinking it LOL.. but I am so LOST
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: Help with job estimate programs

  #9  
Oct 15th, 2006
How about something simple like:

for( int i = 0; i < roomNumber; ++i )
{
   // do what you want here
}
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Oct 2006
Location: Memphis, TN
Posts: 8
Reputation: Eadams20 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Eadams20's Avatar
Eadams20 Eadams20 is offline Offline
Newbie Poster

Re: Help with job estimate programs

  #10  
Oct 15th, 2006
Thanks so much. I had to scrap all of that and put my functions back in LOL... now it works perfect!! Thanks for all the help!! :cheesy:

Originally Posted by ~s.o.s~ View Post
How about something simple like:

for( int i = 0; i < roomNumber; ++i )
{
   // do what you want here
}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 12:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC