# something wrong with my project?

Page 1 of 1

## 3 Replies - 579 Views - Last Post: 08 March 2010 - 12:45 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=160623&amp;s=326ac374caa23a8ac4071c11f25f4794&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Likeitbright

Reputation: 0
• Posts: 6
• Joined: 08-February 10

# something wrong with my project?

Posted 08 March 2010 - 11:01 AM

The program reads the weight in pounds and ounces and outputs the equivalent weight in kilograms and grams. I also included a loop. The problem is I cant call the function. Any help would be appericated.
```#include <iostream>
using namespace std;
double grams(double kilo);
double kilo(double pounds, double ounces, double po);
int main()
{
double pounds, ounces, kilo, grams, weight, po, kilos, gram, kilo2;
char P, o , p, O, select, ans;
do

{
cout <<"Please enter weight in pounds and ounces.n/";
cin >> pounds, ounces;

kilos = kilo(pounds, ounces, po)
gram = grams(kilo2)

cout << "The weight in kilograms"<< kilos <<".n/";
cout << "The weight in grams"<< gram <<".n/";
cout << "Try again? Y/N n\";
cin >> ans;
}
while (ans == 'Y' || ans == 'y');

double grams(double kilo)
{
grams = kilo * 1000

return 1
}
double kilo(double pounds, double ounces, double po)
{
po = ounces * 16
kilo = 2.2046(po+pounds)
kilo = kilo2
return 1
}

```

Is This A Good Question/Topic? 0

## Replies To: something wrong with my project?

### #2 sarmanu

• D.I.C Lover

Reputation: 966
• Posts: 2,362
• Joined: 04-December 09

## Re: something wrong with my project?

Posted 08 March 2010 - 11:09 AM

1. Your functions are implemented in main(). They should be implemented outside.
2. Tons of semicolons are missing.
3. ".n/" should be "\n".
4. You have defined variables with the same name as the functions names.
5. No matter of the instructions from your functions, you are returning 1.

Please, learn the syntax, then start coding

### #3 Likeitbright

Reputation: 0
• Posts: 6
• Joined: 08-February 10

## Re: something wrong with my project?

Posted 08 March 2010 - 11:40 AM

So I fix most the code but I keep getting stuck on the function at the bottom.
```#include <iostream>
using namespace std;

int main()
{
double pounds, ounces, weight, kilos, grams;
char select, ans;

double kilo(double pounds, double ounces);
do
{
cout <<"Please enter weight in pounds and ounces.\n";
cin >> pounds, ounces;

kilos = kilo(pounds, ounces);
grams = 1000 * kilos;

cout << "The weight in kilograms" << kilos << ".\n";
cout << "The weight in grams"<< grams <<".\n";
cout << "Try again? Y/N \n";
cin >> ans;
}
while (ans == 'Y' || ans == 'y');

{
double kilo(double pounds, double ounces)

kilo = 2.2046((ounces*16)+pounds);
return kilo
}

```

### #4 sarmanu

• D.I.C Lover

Reputation: 966
• Posts: 2,362
• Joined: 04-December 09

## Re: something wrong with my project?

Posted 08 March 2010 - 12:45 PM

```#include <iostream>
using namespace std;

double kilo(double, double);

int main()
{
double pounds, ounces, weight, kilos, grams;
char select, ans;

// remove function prototype

do
{
cout <<"Please enter weight in pounds and ounces.\n";
cin >> pounds >> ounces; // >>>> corrected cin

kilos = kilo(pounds, ounces);
grams = 1000 * kilos;

cout << "The weight in kilograms" << kilos << ".\n";
cout << "The weight in grams"<< grams <<".\n";
cout << "Try again? Y/N \n";
cin >> ans;
}while (ans == 'Y' || ans == 'y');