Link to home
Start Free TrialLog in
Avatar of cricket9601
cricket9601

asked on

Money Conversion problem

I am writing a currency conversion program.  I need to print five currencies from one US Dollar amount.  Here is what I have.  I have tested letter input and need to test negative numbers.  What is wrong?


#include <stdio.h>       /*Use this .h file for input, output and get; standard library for programs functional use*/
#include <ctype.h>       /*Use this .h file to test user input*/


 /* print Money Conversion
  *Cricke9601
  *Last Update: 4/3/2006

  *The purpose of this program is for a user to convert US Dollars to

  *Euro Dollars: conversion rate ==.833678
  *Canada Dollars:conversion rate ==1.167
  *Japanese Yen:conversion rate ==117.775
  *Switzerland Francs:conversion rate ==1.3025
  *Australia Dollars:conversion rate ==1.39567

  *Version 2.0--user conversion:
  */

main()                                    /*declares the start of the function*/
  {                                    /*begin local variable*/
                                         /**/
     char cResponse = '\0';
   
           
     printf("\t\t\t\tCurrency Conversion\n\n\n\n");            /*tabs to center then displays title and skips four lines*/

     printf("Welcome to the Currency Conversion Program, Version 2.0\n\n"); /*welcome user line*/
     
   
     printf("\nPlease enter the amount of money you want to convert.\n\n");   /*prompts user to enter $amount*/
     printf("\nYour amount must be in numbers: \n\n\n\n");                  
     
     scanf("%s", &cResponse);
     
   
        if (isdigit (cResponse) )                        /*Create if,else stucture and input val; no need to surround isdigit function*/
           printf("\nThank you\n\n\n");                      /*with parentheses as long as function returns Boolean, true or false, value.*/
                     
        else
           printf("\nYou did not enter a valid number\n");      /*if entered data is not a number, print this*/
           
   
   

    printf("%s %.2f %s", "US Dollar equals", %cResponse*.833678, "Euro Dollars\n\n");     /*displays entered dollars == Euro*/
    printf("%s %.2f %s", "US Dollar equals", %cResponse*1.167, "Canada Dollars\n\n");   /*displays entered dollars == Canadian*/
    printf("%s %.2f %s", "US Dollar equals", %cResponse*117.775, "Japanese Yen\n\n");   /*displays entered dollars == Japanese*/
    printf("%s %.2f %s", "US Dollar equals", %cResponse*1.3025, "Switzerland Francs\n\n");  /*displays entered dollars == Swizerland*/
    printf("%s %.2f %s", "US Dollar equals", %cResponse*1.39567, "Australia Dollars\n\n\n\n");   /*displays entered dollars == Australian*/
     
     
   
   
     printf ("Press any key to continue...\n\n");      /*displays end of program and double space*/


getch ();                              /*wait for user entry*/
return 0;

}                                    /*end local variable*/




 






 
ASKER CERTIFIED SOLUTION
Avatar of F. Dominicus
F. Dominicus
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial