# void function Problem

Page 1 of 1

## 4 Replies - 367 Views - Last Post: 25 November 2012 - 11:18 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=301617&amp;s=b5fb7f5d86ef23878bae53fad5f002bb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 phanton612

Reputation: 0
• Posts: 9
• Joined: 13-November 12

# void function Problem

Posted 25 November 2012 - 10:42 PM

Write a program that displays the status of an order. The program should have a function that asks for the following data:

1. The number of spools ordered
2. The number of spools in stock
3. If there are special shipping and handling charges
(Shipping and handling is normally \$10 per spool) If there are special charges, it should ask for special charges per spool.

The gathered data should be passed as arguments to another function that displays:

1. The number of spools ready to ship from current stock.
2. The number of spools on backorder (if the number ordered is greater than what is in stock)
3. Subtotal of the portion ready to ship (the number of spools ready to ship times \$100)
4. Total shipping and handling charges on the portion ready to ship
5. Total of the order ready to ship

The shipping and handling parameter in the second function should have the default arguments 10.00.

Input validation:

1. Do not accept numbers less than 1 for spools ordered
2. Do not accept number less than 0 for spools in stock or shipping and handling charges.

Quote

It tells me that spoolsordered is undeclared?

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

void orderInfo(int& spoolsordered, int& spoolsinstock, double& specialcharges);
void display(int spoolsordered, int spoolsinstock, double specialcharges);

int main()
{
orderedInfo(spoolsordered, spoolsinstock, specialcharges);
cout << " the spoolsordered is " << spoolsordered << " ";

system("pause");
return 0;
}

////////////////////////////////////////////////////////////////////////////////
void orderInfo(int& spoolsordered, int& spoolsinstock, double& specialcharges)
{
cout << " Please enter the number spools ordered: ";
cin >> spoolsordered;

cout << " Please enter the spools in stock: ";
cin >> spoolsinstock;

cout << " Please enter any specail charges: ";
cin >> specialcharges;
}
////////////////////////////////////////////////////////////////////////////////
```

Is This A Good Question/Topic? 0

## Replies To: void function Problem

### #2 jjl

• Engineer

Reputation: 1169
• Posts: 4,785
• Joined: 09-June 09

## Re: void function Problem

Posted 25 November 2012 - 10:45 PM

Function parameters are not simply placeholders, they are meant to be passed into a function.

### #3 phanton612

Reputation: 0
• Posts: 9
• Joined: 13-November 12

## Re: void function Problem

Posted 25 November 2012 - 11:01 PM

jjl, on 25 November 2012 - 10:45 PM, said:

Function parameters are not simply placeholders, they are meant to be passed into a function.

so would i just clear out all the stuff inside the parameters?

like

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

void orderInfo();
void display(int spoolsordered, int spoolsinstock, double specialcharges);

int main()
{
orderedInfo();
cout << " the spoolsordered is " << spoolsordered << " ";

system("pause");
return 0;
}

////////////////////////////////////////////////////////////////////////////////
void orderInfo()
{
cout << " Please enter the number spools ordered: ";
cin >> spoolsordered;

cout << " Please enter the spools in stock: ";
cin >> spoolsinstock;

cout << " Please enter any specail charges: ";
cin >> specialcharges;
}
////////////////////////////////////////////////////////////////////////////////
```

when i do that it just says orderInfo is undeclared

### #4 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,449
• Joined: 14-September 12

## Re: void function Problem

Posted 25 November 2012 - 11:13 PM

You also need to look into the names of functions...orderedInfo and orderInfo are considered as two different functions...

Also, for your spoolsordered, spoolsinstock and specialcharges, they need to be declared first before they can be initialized.

regards,
Raghav

### #5 jjl

• Engineer

Reputation: 1169
• Posts: 4,785
• Joined: 09-June 09

## Re: void function Problem

Posted 25 November 2012 - 11:18 PM

Quote

so would i just clear out all the stuff inside the parameters?

No, you need to define the variables within main and then pass them as parameters. Your function accepts references to variables, therefore they need memory to reference from.