Functions, so many functions...

Given this code:
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
#include <iostream>
using namespace std;

const double GramsPerOunce = 28.35; 
const double GramsPerTroyOunces = 31.1; 
const double CurrentValuePerTroyOunceGold = 1744.50;
const double FullKarat = 24;

int main ()
{
  unsigned int Weight;
  double Grams, TroyOunces, FullValue, Karats, AdjustedValue;

  cout << "Please enter your weight of Gold in ounces => ";
  cin >> Weight;
  cout << endl << endl;

  cout << "Please enter the Quality of gold in Karats => ";
  cin >> Karats;
  cout << endl << endl;


  Grams = Weight * GramsPerOunce;	 

  TroyOunces = Grams / GramsPerTroyOunces;

  FullValue = TroyOunces * CurrentValuePerTroyOunceGold;

  AdjustedValue = FullValue * Karats / FullKarat;

		
  cout << "Your "<< Weight << " ounces of Gold with a Karat Quality of " << Karats << " is $" << AdjustedValue << endl  << endl;
	
  system("pause");
  return(0);
}


I need to modify it's code to include three functions:
1. Get the weight
2. Calculate the value
3. Print the results

What I have so far is... probably not even right.

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
#include <iostream>
using namespace std;

const double GramsPerOunce = 28.35; 
const double GramsPerTroyOunces = 31.1; 
const double CurrentValuePerTroyOunceGold = 1744.50;
const double FullKarat = 24;
double GetWeight (double Weight);
double CalculateKarats (double Karats);
double CalculateValue ();
void PrintValue (double AdjustedValue);

int main ()
{
	CalculateWeight;
	CalculateKarats;
	CalculateValue;
	PrintValue;


  system("pause");
  return(0);
}

void PrintValue (double AdjustedValue, double Weight, double Karats)
{
	cout << "Your "<< Weight << " ounces of Gold with a Karat Quality of " << Karats << " is $" << AdjustedValue << endl  << endl;
}

double GetWeight (double Weight)
{
	cout << "Please enter your weight of gold in ounces => " << endl;
	cin >> Weight;
	cout << endl << endl;
	return(Weight);
}

double CalculateKarats (double Karats)
{
	cout << "Please enter the Quality of gold in Karats => ";
	cin >> Karats;
	cout << endl << endl;
	return(Karats);
}

double CalculateValue (double Grams, double Karats, double Weight, double TroyOunces, 
				double GramsPerOunce, double GramsPerTroyOunces, double FullValue, 
				double CurrentValuePerTroyOunceGold, double AdjustedValue, double FullKarat)
{
	Grams = Weight * GramsPerOunce;	 
	TroyOunces = Grams / GramsPerTroyOunces;
	FullValue = TroyOunces * CurrentValuePerTroyOunceGold;
	AdjustedValue = FullValue * Karats / FullKarat;

	cin >> AdjustedValue;

	return (AdjustedValue);
}


I'm especially confused about what to even put in main, which is why it's pretty much empty. Note I haven't learned arrays or any of that awesomeness. It's bare bones C++ here.

Any direction would be highly appreciated.
Check http://www.cplusplus.com/doc/tutorial/functions/ to answer your questions.
Topic archived. No new replies allowed.