[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Statements vs equations

Posted on 2007-10-06
6
Medium Priority
?
359 Views
Last Modified: 2010-08-05
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>

main()

{
//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?
0
Comment
Question by:alwright1975
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:UrosVidojevic
ID: 20028854
Are you trying to make program which will convert currencies?
0
 

Author Comment

by:alwright1975
ID: 20028864
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?
0
 
LVL 7

Accepted Solution

by:
UrosVidojevic earned 2000 total points
ID: 20028889
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);
   
    getchar();
    getchar();
   
    return 0;
}
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 7

Expert Comment

by:UrosVidojevic
ID: 20028901
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.

Notes:

* '\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.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20028905
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. :

        http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

Note that there are several format specifiers you can use to show variables. Take a look at the example code on that page too.
0
 

Author Comment

by:alwright1975
ID: 20029015
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!!!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question