Feb 24, 2012 at 4:59pm UTC
Can some one give me a hand with this code,i know i must use cmath library.
Last edited on Feb 24, 2012 at 5:13pm UTC
Feb 24, 2012 at 5:16pm UTC
A program that computes the size of a dog house with the cost per square foot is 15.50 euros with the user entering their budgeted amount ok
Feb 24, 2012 at 5:17pm UTC
I don't understand your question.
You need to use <cmath> if you use sqrt(15.5);
Feb 24, 2012 at 5:32pm UTC
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double budget ;
cout<< budget 10 / sqrt (15.50);
cin>> budget;
system("pause");
return 0;
}
Is it like that and change budget to a number
Feb 24, 2012 at 5:38pm UTC
you forgot to declare your doghouse. you can use mine :
void doghouse (int ***, int***, int***) //3 dimensional doghouse
then you can call it whenever you'd like.
(also)
cin>> budget; //input
cout<< budget / sqrt (15.50); //output
(should work better)
Last edited on Feb 24, 2012 at 5:42pm UTC
Feb 24, 2012 at 5:47pm UTC
ok will try that cheers,should i put the cin before the cout
Feb 24, 2012 at 5:52pm UTC
#include <iostream>
#include <cmath>
void doghouse (int lenght = 10 , int with = 10, int height = 5);
using namespace std;
int main ()
{
double budget ;
cout<< 10 / sqrt (15.50);
cin>> budget doghouse;
system("pause");
return 0;
}
like that is it
Feb 24, 2012 at 6:01pm UTC
ok it complided, now can i just put a euro sign in front of the 15.50
Feb 24, 2012 at 6:05pm UTC
no, you have to use EuroC++ if you want to complide euros. Standard C++ only complides with $!
Remember that your doghouse only works if dogs are using them!
Feb 24, 2012 at 6:06pm UTC
Try this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double budget ;
cout << "Enter your budget: " ;
cin>> budget;
cout<< "You can build a doghouse this big: " << budget / sqrt (15.50);
system("pause" );
return 0;
}
Last edited on Feb 24, 2012 at 6:07pm UTC
Feb 24, 2012 at 6:18pm UTC
#include <iostream>
#include <cmath>
//void doghouse (int lenght = 10 , int with = 10, int height = 5);
using namespace std;
int main ()
{
double budget ;
cout << "Enter your budget: ";
cin>> 10;
cout<< "length = 10,with = 10,height = 5, " << 10 / sqrt (15.50);
system("pause");
return 0;
}
can't get that to compile sor
Feb 24, 2012 at 6:34pm UTC
you forgot to declare the dogs for your doghouse.
use this :
void dog(int) {
cout<<"Woof woof woof I am a happy dog";
}
then in your main :
int main() {
int Rex, dog2;
dog(Rex);
dog(dog2);
doghouse(length (in milemetres), with (in milimetres), height (in meters) )
}
don't forget that dogs have to eat and sleep as well, so declare your eating, playing and sleeping functions accordingly.
if you don't want to go that far: use Stewbond's code
Feb 24, 2012 at 6:35pm UTC
cin >> something
means that you are entering a number into the variable 'something'.
You can do cin>>10
. In this line you are trying to enter a number into the constant number 10 which doesn't make any sense.
And yeah, you can get rid of
void doghouse (int lenght = 10 , int with = 10, int height = 5)
timmyyy was messing with you.
Feb 24, 2012 at 6:51pm UTC
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double budget ;
cout << "Enter your budget: ";
cin>> budget;
cout<< "length = 5(meter's),with = 5(meter's),height = 5(meter's) , "<< budget / sqrt (15.50);
system("pause");
return 0;
}
like that,it will compile but meters in() on screen,will i declare meter's as a char