#include <stdio.h>

// Constant conversion factors.
#define DOLLAR_EURO 0.69     // 1 dollar = 0.69 euro
#define DOLLAR_YEN 116.00    // 1 dollar = 116.00 yen
#define EURO_YEN 166.60      // 1 euro = 166.60 yen

int main() {

	// input variables.
	char src_type, dst_type;
	double src_value;
	
	// output variable (computed)
	double dst_value;
	
	// dummy newline variable to absorb user's <Enter> keystroke.
	char nl;
	
	// boolean variable to indicate whether or not both currency
	// types are valid.
	char success;
	
	// get inputs (source type, destination type, and source value).
	printf("Enter the source currency: ");
	scanf("%c%c", &src_type, &nl);
	
	printf("Enter the destination currency: ");
	scanf("%c%c", &dst_type, &nl);
	
	printf("Enter the value: ");
	scanf("%lf", &src_value);
	
	// assume successful; set to false (0) if we find an error.
	success = 1;
	
	// determine the source and destination types, and convert as required.
	switch (src_type) {
		case '$':
			if (dst_type == '$') dst_value = src_value;
			else if (dst_type == 'Y') dst_value = src_value * DOLLAR_YEN;
			else if (dst_type == 'E') dst_value = src_value * DOLLAR_EURO;
			else success = 0;
			break;
		
		case 'Y':
			if (dst_type == '$') dst_value = src_value / DOLLAR_YEN;
			else if (dst_type == 'Y') dst_value = src_value;
			else if (dst_type == 'E') dst_value = src_value / EURO_YEN;
			else success = 0;
			break;
		
		case 'E':
			if (dst_type == '$') dst_value = src_value / DOLLAR_EURO;
			else if (dst_type == 'Y') dst_value = src_value * EURO_YEN;
			else if (dst_type == 'E') dst_value = src_value;
			else success = 0;
			break;
		
		default:
			success = 0;
	}
	
	// Output conversion, or error message if invalid type.
	if (success) {
		printf("%c%.2lf = %c%.2lf\n", src_type, src_value, dst_type, dst_value);
	} else {
		printf("There was an error with the input.\n");
	}
	
	return 0;
}

