I have been trying to figure out functions for a while now, and I have been working with a specific program for a week, and have been unable to figure out what I am doing wrong.
Here is the 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 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
|
#include <iostream>
using namespace std;
void GetTheWeight(double & Weight);
void GetTheKarats(double & Karats);
void CalculateTheValue(double Weight, double Karats);
const double GramsPerOunce = 28.35;
const double GramsPerTroyOunces = 31.1;
const double CurrentValuePerTroyOunceGold = 1744.50;
const double FullKarat = 24;
int main ()
{
double Weight;
double Karats;
double TroyOunces;
double Grams;
double FullKarats;
double AdjustedValue;
GetTheWeight(Weight);
GetTheKarats(Karats);
CalculateTheValue(Weight, Karats);
cout << "Your "<< Weight << " ounces of Gold with a Karat Quality of " << Karats << " is $" << AdjustedValue << endl << endl;
return(0);
}
void GetTheWeight (double & Weight)
{
cout << "Please enter your weight of Gold in ounces => ";
cin >> Weight;
cout << endl << endl;
}
void GetTheKarats(double & Karats)
{
cout << "Please enter the Quality of gold in Karats => ";
cin >> Karats;
cout << endl << endl;
}
void CalculateTheValue(double Weight, double Karats)
{
double Grams;
double TroyOunces;
double FullValue;
double AdjustedValue;
Grams = Weight * GramsPerOunce;
TroyOunces = Grams / GramsPerTroyOunces;
FullValue = TroyOunces * CurrentValuePerTroyOunceGold;
AdjustedValue = FullValue * Karats / FullKarat;
}
|
========================================
This is the Error I receive while trying to build.
========================================
1>------ Build started: Project: functions, Configuration: Debug Win32 ------
(20): warning C4101: 'FullKarats' : unreferenced local variable
(19): warning C4101: 'Grams' : unreferenced local variable
(18): warning C4101: 'TroyOunces' : unreferenced local variable
(27): warning C4700: uninitialized local variable 'AdjustedValue' used
functions\Debug\functions.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
=========================================
I am at my wits end, any help would be greatly appreciated.