Help in solving problem in C programming
Not what you're looking for?
Please keep the program in the orginal form. I am writing in C program using a C compiler.
Need help at the end of the program. It needs a DO-WHILE statement at the end. Selecting Y should go to the main menu. Selecting N should print "The End".
getch (); and return (0); must be at the end of my compiler to work.
do{
printf ("Would you like to convert another currency? Y or Nn")
}while
/*Currency conversion.*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <system.h>
main ()
{
/* Data Declaration statements*/
int Curr_type;
float For_curr;
float Equ_curr;
int choice;
printf("CURRENCY CONVERTERn");
printf("Choose currency optionn");
printf("Press 1 for MXN: Mexican Peson");
printf("Press 2 for JPY: Japanese Yenn");
printf("Press 3 for HKD: Hong Kong Dollarsn");
printf("Press 4 for KRW: Korean Wonn");
printf("Press 5 for PHP: Philippine Peson");
printf("Enter the type of currency:");
scanf("%d", &Curr_type);/* & symbol assigns L-H and R-H to the left hand quantity*/
printf("Enter the amount in USD that you would like to convert to foreign currency:n");
scanf("%f", &For_curr);
/* Switch statement to Case Curr_type (1, 2, 3, 4, 5)*/
switch(Curr_type)
{
/* MXN: Mexican Peso */
case 1:
Equ_curr = ((For_curr) / (0.08764));
printf ("The equivalent of %.2f USD is %.2f MXN n", For_curr, Equ_curr);
break; /* Jump to end of switch*/
/* JPY: Japanese Yen */
case 2:
Equ_curr = ((For_curr) / (0.009093));
printf ("The equivalent of %.2f USD is %.2f JPY n", For_curr, Equ_curr);
break; /* Jump to end of switch*/
/* HKD: Hong Kong Dollars */
case 3:
Equ_curr = ((For_curr) / (0.1283));
printf ("The equivalent of %.2f USD is %.2f HKD n", For_curr, Equ_curr);
break; /* Jump to end of switch*/
/* KRW: Korean Won */
case 4:
Equ_curr = ((For_curr) / (0.0008591));
printf ("The equivalent of %.2f USD is %.2f KRW n", For_curr, Equ_curr);
break; /* Jump to end of switch*/
/* PHP: Philippine Peso */
case 5:
Equ_curr = ((For_curr) / (0.01791));
printf ("The equivalent of %.2f USD is %.2f PHP n", For_curr, Equ_curr);
break; /* Jump to end of switch*/
/*Other: Currency of any other country */
default:
printf("We are sorry, this system doesn't support conversion for this currencyn");
} /*end switch */
getch ();
return (0);
}
Purchase this Solution
Purchase this Solution
Free BrainMass Quizzes
Basic UNIX commands
Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.