Help with C++ void function program

Here is the assignment:
a. The program has no functions. Modify the program so that it uses only void functions. You need:
1. one function to get the data from the user
2. three functions for the calculations (wood, canvas, total)
3. one function to print the output.
b. Write each function parameter on a line by itself and indicate with a comment if the parameter is /*in*/ or /*out*/
c. Write preconditions and postconditions for each function
(I can't use arrays)

This is what I got so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//******************************************************************
// Canvas program
// This program computes the dimensions and costs of materials
// to build a painting canvas of given dimensions. The user is
// asked to enter the length and width of the painting and the
// costs of the wood (per inch) and canvas (per square inch)
//******************************************************************
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <fstream>

using namespace std;

void FindData(double, double, double, double);
void FindWood(double&, double&, double);
void FindCanvas(double&, double&);
void FindTotalCost(double&, double&, double&);
void PrintResults();

const int OVERLAP = 5; // Extra inches needed for canvas overlap on frame

int main()
{
double length; // Length of painting in inches
double width; // Width of painting in inches
double woodCost; // Cost of wood per inch in dollars
double canvasCost; // Cost of canvas per square foot
double lengthOfWood; // Amount of wood to buy
double canvasWidth; // Width of canvas to buy
double canvasLength; // Length of canvas to buy
double canvasAreaInches; // Area of canvas in square inches
double totalCanvasCost; // Total cost of canvas being bought
double totalWoodCost; // Total cost of wood being bought
double totalCost; // Total cost of materials

cout << fixed << showpoint;
FindData(length, width, woodCost, canvasCost);
FindWood(lengthOfWood, totalWoodCost, woodCost);
FindCanvas(canvasAreaInches, totalCanvasCost);
FindTotalCost(totalCanvasCost, totalWoodCost, totalCost);
PrintResults();


getch();
return 0;
}

void FindData(double length, double width, double woodCost, double canvasCost)
{
cout << "Enter length and width of painting:" << endl;
cin >> length >> width;

cout << "Enter cost per inch of the framing wood in dollars:"
<< endl;
cin >> woodCost;

cout << "Enter cost per square inch of canvas in dollars:"
<< endl;
cin >> canvasCost;
}

void FindWood(double& lengthOfWood, double& totalWoodCost, double woodCost, double& length, double& width)
{
lengthOfWood = (length + width) * 2;
totalWoodCost = lengthOfWood * woodCost;
}

void FindCanvas(double& canvasAreaInches, double& totalCanvasCost, double& width, double& length, double& canvasCost, double& canvasWidth, double& canvasLength)
{
canvasWidth = width + OVERLAP;
canvasLength = length + OVERLAP;
canvasAreaInches = canvasWidth * canvasLength;
totalCanvasCost = canvasAreaInches * canvasCost;
}

void FindTotalCost(double& totalCanvasCost, double& totalWoodCost, double& totalCost)
{

totalCost = totalWoodCost + totalCanvasCost;
}

void PrintResult(double& length, double& width, double& lengthOfWood, double& canvasLength, double& canvasWidth, double& woodCost, double& canvasCost, double& totalWoodCost, double& totalCanvasCost, double& totalCost)
{
// Print the dimensions
cout << endl << setprecision(1);
cout << "Painting is " << length << " in. long and "
<< width << " in. wide." << endl;
cout << setw(5) << ' ' << "Buy " << lengthOfWood << " in. of wood." << endl;
cout << setw(5) << ' ' << "Buy a " << canvasLength << " in. by "
<< canvasWidth << " in. canvas" << endl;

//Print the costs
cout << endl << setprecision(2);
cout << "The wood costs $" << woodCost << " per in." << endl;
cout << "The canvas costs $" << canvasCost << " per sq. in." << endl;
cout << endl;
cout << "Your costs will be: " << endl;
cout << setw(5) << ' ' << "Wood cost - $" << totalWoodCost << endl;
cout << setw(5) << ' ' << "Canvas cost - $" << totalCanvasCost << endl;
cout << "Total cost of materials $" << totalCost << endl;
}


But I keep getting errors
Please help.
closed account (DSLq5Di1)
Would be nice if you posted the errors, and some indentation wouldn't go astray.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void PrintResults(); // ???
void PrintResult(double& length, double& width, double& lengthOfWood, double& canvasLength, double& canvasWidth, double& woodCost, double& canvasCost, double& totalWoodCost, double& totalCanvasCost, double& totalCost)
{
    ...
}

void FindCanvas(double&, double&); // ???
void FindCanvas(double& canvasAreaInches, double& totalCanvasCost, double& width, double& length, double& canvasCost, double& canvasWidth, double& canvasLength)
{
    ...
}

void FindWood(double&, double&, double); // ???
void FindWood(double& lengthOfWood, double& totalWoodCost, double woodCost, double& length, double& width)
{
    ...
}

Your function declarations do not match your definitions.
here are the errors


1>------ Build started: Project: Canvas, Configuration: Debug Win32 ------
1> Canvas.cpp
1>c:\users\kendio\downloads\canvas.cpp(47): warning C4996: 'getch': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _getch. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\conio.h(128) : see declaration of 'getch'
1>c:\users\kendio\downloads\canvas.cpp(32): warning C4101: 'canvasWidth' : unreferenced local variable
1>c:\users\kendio\downloads\canvas.cpp(33): warning C4101: 'canvasLength' : unreferenced local variable
1>c:\users\kendio\downloads\canvas.cpp(40): warning C4700: uninitialized local variable 'canvasCost' used
1>c:\users\kendio\downloads\canvas.cpp(40): warning C4700: uninitialized local variable 'woodCost' used
1>c:\users\kendio\downloads\canvas.cpp(40): warning C4700: uninitialized local variable 'width' used
1>c:\users\kendio\downloads\canvas.cpp(40): warning C4700: uninitialized local variable 'length' used
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl PrintResults(void)" (?PrintResults@@YAXXZ) referenced in function _main
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl FindCanvas(double &,double &)" (?FindCanvas@@YAXAAN0@Z) referenced in function _main
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl FindWood(double &,double &,double)" (?FindWood@@YAXAAN0N@Z) referenced in function _main
1>C:\Users\Kendio\Documents\Visual Studio 2010\Projects\Canvas\Debug\Canvas.exe : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I thought there were supposed to be like that
The examples from the book were different from what my teacher showed me.
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl PrintResults(void)" (?PrintResults@@YAXXZ) referenced in function _main
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl FindCanvas(double &,double &)" (?FindCanvas@@YAXAAN0@Z) referenced in function _main
1>Canvas.obj : error LNK2019: unresolved external symbol "void __cdecl FindWood(double &,double &,double)" (?FindWood@@YAXAAN0N@Z) referenced in function _main


Like sloppy said, can you spot the difference between your declarations and your definitions?

1
2
3
void FindWood(double&, double&, double);
void FindCanvas(double&, double&);
void PrintResults();

1
2
3
4
5
void FindWood(double& lengthOfWood, double& totalWoodCost, double woodCost, double& length, double& width)

void FindCanvas(double& canvasAreaInches, double& totalCanvasCost, double& width, double& length, double& canvasCost, double& canvasWidth, double& canvasLength)

void PrintResult(double& length, double& width, double& lengthOfWood, double& canvasLength, double& canvasWidth, double& woodCost, double& canvasCost, double& totalWoodCost, double& totalCanvasCost, double& totalCost)
Topic archived. No new replies allowed.