SOMEONE PLEASE HELP ME!!!:D

this is the program i currently have however it doesnt work and im not sure how to get it to work! many thanks :)

#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip> //for endl
#include <Windows.h>

using namespace 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
{
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
Last edited on
there is a red line inder produceFinalData(); and it says too few arguments in function call. im not sure how i should fix this


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);
}


You've got to give arguments to function call, e.g.
1
2
int sum = 78, nrOfPrices = 98;
produceFinalData(sum, nrOfPrices);

EDIT:
also, your calculateSum function uses sumInEuros variable without initializing it:
1
2
int sumInEuros;
sumInEuros = (sumInEuros + euros);
Last edited on
im a complete noob at this. c++ is a brand new language to me so could you show me how to do it please?
many thanks :)
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.
okay, basically i want the program to convert from pounds to euros
VoilĂ !

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream> //for I/O

using namespace std;

const double PoundsToEuros = 1.34; // double for floating point numbers

int main(){
	char answear;
	unsigned input; // unsigned - only non-negative numbers (0 and up)

	do{
		cout << "Input price in pounds(without pences): ";
		cin >> input;
		cout << input << " pounds is equal to " << input * PoundsToEuros << " euros\n";
		cout << "Do you want to continue (y/n): ";
		cin >> answear;
		cout << std::endl;
	} while (answear == 'Y' || answear == 'y');

	cout << "Bye! Press Enter...";
	cin.get(); // one is skipped due to previous input
	cin.get();
	return(0);
}
Last edited on
thanks for your help. its for a college project so i have to use this format, i know, its stupid haha.

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
#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip> //for endl
#include <Windows.h>

using namespace 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
{
	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);

}
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.
its my own.. i've done all of that code however i got stuck on a little bit, sorry for asking jeeeez
It will be beter if you read some tutorials, it seems you don't know the basics. This seems like a good tutorial: http://www.learncpp.com/
Topic archived. No new replies allowed.