if (numberOfPrices > 0)
//produceFinalData(sum, numberOfPrices);
produceFinalData();
system("PAUSE"); //hold the screen until a key is pressed
return(0);
}
void processAPrice() //processing the given price
{
int pounds = getPriceInPounds();
int euros = convertPriceIntoEuros(pounds);
calculateSum(euros);
}
int getPriceInPounds(int priceInPounds) // get the value
{
cout << "Enter a price (in Pounds): /234";
cin >> priceInPounds;
return priceInPounds;
}
int convertPriceIntoEuros(int priceInPounds) // convert price into euros
{
const int conversionRate(0.82);
return priceInPounds / conversionRate;
}
void showPriceInEuros(int pounds, int euros)
{
SetConsoleOutputCP(1252);
cout << "The Euro value of /234" << pounds << "is: \u20AC" << euros;
}
int calculateSum(int euros) // Calculate the sum
{
int sumInEuros;
sumInEuros = (sumInEuros + euros);
return sumInEuros;
}
void produceFinalData(int sum, int numberOfPrices) // Final Output (answer)
{
SetConsoleOutputCP(1252);
cout << "The total sum is: \u20AC" << sum;
cout << "The average is: \u20AC" << (sum / numberOfPrices);
What do you want to do? Why doesn't it work? It doesn't compile, crashes or something else? Please use code tag: http://www.cplusplus.com/articles/jEywvCM9/
Don't use system(), it's BAD. You can use std::cin.get() instead. Your program takes input, so you've got to use it two times before return 0;
EDIT:
You use your function "produceFinalData" with no arguments in main(), there is no such overload
Maybe get some book, C++ is a HUGE language. There are also internet tutorials. Firstly tell me what do you want to do, 'cuz if you don't know it, I won't know it either.
#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip> //for endl
#include <Windows.h>
usingnamespace std;
void processAPrice();
int getPriceInPounds();
int convertPriceIntoEuros(int pounds);
int calculateSum(int euros);
void produceFinalData(int sum, int numberOfPrices);
int main()
{
char answer('Y');
int numberOfPrices(0);
while ((answer == 'Y') || (answer == 'y'))
{
processAPrice();
numberOfPrices++;
cout << "Continue? (Y/N)";
cin >> answer;
}
if (numberOfPrices > 0)
//produceFinalData(sum, numberOfPrices);
produceFinalData();
system("PAUSE"); //hold the screen until a key is pressed
return(0);
}
void processAPrice() //processing the given price
{
int pounds = getPriceInPounds();
int euros = convertPriceIntoEuros(pounds);
calculateSum(euros);
}
int getPriceInPounds(int priceInPounds) // get the value
{
cout << "Enter a price (in Pounds): /234";
cin >> priceInPounds;
return priceInPounds;
}
int convertPriceIntoEuros(int priceInPounds) // convert price into euros
{
constint conversionRate(0.82);
return priceInPounds / conversionRate;
}
void showPriceInEuros(int pounds, int euros)
{
SetConsoleOutputCP(1252);
cout << "The Euro value of /234" << pounds << "is: \u20AC" << euros;
}
int calculateSum(int euros) // Calculate the sum
{
int sumInEuros;
sumInEuros = (sumInEuros + euros);
return sumInEuros;
}
void produceFinalData(int sum, int numberOfPrices) // Final Output (answer)
{
SetConsoleOutputCP(1252);
cout << "The total sum is: \u20AC" << sum;
cout << "The average is: \u20AC" << (sum / numberOfPrices);
}
Where is this code from? Is this from your teacher, from book, it's your own or it's from somewhere else? I showed you how to do it, you can change this code. Nobody is going to do projects for you, so you can graduate the school.