• C

Statements vs equations

I am haveing a problem. I am supose to use hard coded equations  to get this results.

Currency Conversion
1.00 Euro = 1.28 US Dollar
1.00 UK Pound = 1.87 US Dollar
1.00 Japanese Yen = 0.01 US Dollar
1.00 Canadian Dollar = 0.82 US Dollar
1.00 Australian Dollar = 0.77 US Dollar

I got the above display with this...

#include <studio.h>


//Title of program
printf("Currency Conversion\n");
//List of Conversions
printf("1.00 Euro = 1.28 US Dollar\n");
printf("1.00 UK Pound = 1.87 US Dollar\n");
printf("1.00 Japanese Yen = 1.01 US Dollar\n");
printf("1.00 Canadian Dollar = 0.82 US Dollar\n");
printf("1.00 Australian Dollar = 0.77 US Dollar\n");


but they are not equations...how can I convert these statments to equations?
Who is Participating?
UrosVidojevicConnect With a Mentor Commented:
I suppose you need this?

#include <stdio.h>

int main() {
    int choice;
    double coef, amount, res;
    printf("Choose currency:\n\n");
    printf("\t1.) Euro\n");
    printf("\t2.) UK Pound\n");
    printf("\t3.) Japanese Yen\n");
    printf("\t4.) Canadian Dollar\n");
    printf("\t5.) Australian Dollar\n\n");

    printf("Your choice is: ");
    scanf("%d", &choice);
    switch (choice) {
           case 1: coef = 1.28; break;
           case 2: coef = 1.87; break;
           case 3: coef = 0.01; break;
           case 4: coef = 0.82; break;
           case 5: coef = 0.77; break;
    printf("\nEnter amount: ");
    scanf("%lf", &amount);
    res = amount * coef;
    printf("Amount in American dollars: %6.2Lf.", res);
    return 0;
Are you trying to make program which will convert currencies?
alwright1975Author Commented:
yes, my fist step is to use hard coded equations to display what i showed above. Then I have to build on it to write one with a menu to chose which converstion, then to allow user to enter amount to convert and I am lost and confused?
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

This program:

- Prints the menu.
- Reads the choice to the variable "choice".
- Depending of what did user choose, we have different coefficients.
- Reads the amount of money.
- Multiplies the amount of money with coefficient.
- Prints the result.


* '\n' - new line
* '\t' - tab
* when you want to read some variable you must use & in front of it.
* when you want to print it you don't use &.
* when you want to read or print double variable you must use %lf in printf or scanf.
UrosVidojevic, please don't just give code that is meant for an assignment. The goal for alwright1975 is to learn something - not to just get a solution handed on a platter.

alwright1975, what you want to do is store the conversion values in some variables (an array would be nice). Then, you can retrieve those values, and use them to show the conversion rates to the user.

Take a look at the reference page for printf eg. :


Note that there are several format specifiers you can use to show variables. Take a look at the example code on that page too.
alwright1975Author Commented:
Thank you both, Infinity08 and UrosVidojevic all was very helpful. Also even thought it was great code I still have to tweak it to fit the requirment for my 3 assignments. This gave me an idea of how it works and what I needed to do to change it to the requirment. Thank you both again very much!!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.