Solved

Print out question

Posted on 2004-08-09
7
240 Views
Last Modified: 2010-04-15
I am baffled. Why can I not get this 'The selected currency type is the Canadian DOllars of 1.317510 equivalant to 1.0
00000 US  Dollar" to print out? Thanks

/*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{
 
int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 while(1){
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

 option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
               

 
 
 
0
Comment
Question by:Rfusco
  • 3
  • 2
  • 2
7 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 11758401
Apparently you must see this line. But, first of all, do you see currency menu? (Select a currency type, etc...)

0
 

Author Comment

by:Rfusco
ID: 11758424
These are the only three lines that print out. Thanks

Select a currency type

1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles

Select the 4=Canadian Dollars currency type
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11758458
I can figure if getch() is working correctly. Which compiler are you using?
Also you can try with:

scanf("%c", &option);

You have to type the digit and press enter (with getch() don't need to press enter)
A cursor will appear while you type your option.
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 3

Expert Comment

by:realrael
ID: 11759011

if you need to use getch(), you have to declare its header. - rael

---

#include <conio.h>
0
 
LVL 3

Expert Comment

by:realrael
ID: 11759190

just curious, how did this get solved? - rael
0
 

Author Comment

by:Rfusco
ID: 11766147
Do not LOL but I did not realize that I had to enter in the 4 to select the numberfrom the program. I thought that it would select it by default and ignore the others. Thanks for asking :-)
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11766232
Now I  know why I have received a C (I don't ask usually)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best UNIX-compatible free C compiler for Windows or Mac 6 238
List out all word 7 259
Global Keyboard Hooks Blocked 4 70
Why isn't object file created? 6 42
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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now