#include <cstdlib>
#include <iostream>
usingnamespace std;
//funkcijos
int a();
int b();
int c();
int d();
int e();
int f();
int g();
int h();
int i();
int j();
int k();
int l();
//funkcijos
//meniu
int main (void)
{
//pristatymas
cout <<"This is a currency converter.It helps to convert 4 currencies between."<<endl;
cout << endl;
cout << endl;
//pristatymas
// pasirinktys
char ch;
cout <<"Please select one of the currencies."<<endl;
cout <<"Select a letter and press enter"<<endl;
cout << endl;
cout <<"a > EUR-LT,b > USD-LT,c > GBP-LT"<<endl;
cout << endl;
cout <<"d > LT-EUR,e > LT-USD,f > LT-GBP"<<endl;
cout << endl;
cout <<"g > EUR-USD,h > EUR-GBP,i > GBP-EUR"<<endl;
cout << endl;
cout <<"j > USD-EUR,k > GBP-USD,l > USD-GBP"<<endl;
cout <<endl;
cout <<"If you want to finish type # and press enter."<<endl;
while ((ch=getchar())!='#')
{
if(ch!=' ')
switch(ch)
{
case'a':cout << "EUR-LT\n" << endl;cout << a();
break;
case'b':cout << "USD-LT\n" << endl;cout << b();
break;
case'c':cout << "GBP-LT\n" << endl;cout << c();
break;
case'd':cout << "LT-EUR\n" << endl;cout << d();
break;
case'e':cout << "LT-USD\n" << endl;cout << e();
break;
case'f':cout << "LT-GBP\n" << endl;cout << f();
break;
case'g':cout << "EUR-USD\n" << endl;cout << g();
break;
case'h':cout << "EUR-GBP\n" << endl;cout << h();
break;
case'i':cout << "GBP-EUR\n" << endl;cout << i();
break;
case'j':cout << "USD-EUR\n" << endl;cout << j();
break;
case'k':cout << "GBP-USD\n" << endl;cout << k();
break;
case'l':cout << "USD-GBP\n" << endl;cout << l();
break;
}
else
cout << "You have pressed space button , if you want to continue enter a letter or enter # to finish\n"<<endl;
}
}
// pasirinktys
//meniu
//Euro skaiciavimas
int a()
{
double a,b,c;
c=3.4420 ;
cout << "Enter EUR amount\n" << endl;
cin >> a;
cout << endl;
b=a*c ;
cout << a << "EUR is " << b <<"LT"<<endl;
cout << endl;
cout << endl;
cout << endl;
return 0 ;
}
It's a currency converter.
I didn't post a full program , cos it's the same later on.
I have a problem:
When I choose something from my programs menu , I write a number , and it counts , this part works , but at the end I get a number 0 , it's like return 0; and it returns , how should I hide the 0?
On line 48: cout << a(); You're printing the return value of a(). If you just want to call a(), simply use a();. However, the correct way of doing it would be to get the value in main, do the operation in the function, and then return the converted value.
By the way, if you have nothing to return, just declare the function's return value as void, and omit the return.