Beginner needs help!!

Thanks
Last edited on
Please could you fix your code tags, do make this more readable?

It looks to me like you've got your use of semicolons and braces horribly messed up in your if statements. The best way to fix this is to go back to your textbook and re-read the sections on if statements, to learn the correct syntax.

Edit You would also help yourself enormously if you adopted a sensible formatting style with regards to indentation, bracing style, putting one statement on a line, etc. This will help you see more easily what your code is doing and where you might be going wrong.
Last edited on
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
#include <iostream>

using namespace std;

int main()
{
double currency1, currency2, amount, result;

cout << "1=Euro 2=Dollars 3=Pounds\n";

cout << "Which currency would you like to convert? ";
cin >> currency1;
cout << "\nWhich currency would you like to convert this to? ";
cin >> currency2;
cout << "\nHow much would you like to convert? ";
cin >> amount;

if (currency1 == 1 && currency2 == 2)
{
 result = amount*//Insert Amount Here 
 cout << result;
}
if (currency1 == 1 && currency2 == 3)
{
 result = amount*//Insert Amount Here 
 cout << result;
}


if (currency1 == 2 && currency2 == 1)
{
 result = amount*//Insert Amount Here 
 cout << result;
}
if (currency1 == 2 && currency2 == 3)
{
 result = amount*//Insert Amount Here 
 cout << result;
}


if (currency1 == 3 && currency2 == 2)
{
 result = amount*//Insert Amount Here 
 cout << result;
}
if (currency1 == 3 && currency2 == 1)
{
 result = amount*//Insert Amount Here 
 cout << result;
}
}


May or may not fully work since I just drew it up here
Hi, welcome to C++ and to this forum.

First of all i suggest you to study how to properly indent your code, put braces and statements under if's line by line to clarify blocks of statement etc...
And also use code tags next time you post -> insert your code between the
tags
[code][/code]
so that your code will be neater.

The main problems for me are:
1. you are putting some braces which are not really needed
2. your if syntax's are wrong
3. your conditional statements inside ifs are wrong, if we want to compare 2 values, we use == operator, not =

I suggest you read:
http://www.cplusplus.com/doc/tutorial/control/
Last edited on
Topic archived. No new replies allowed.