Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,083 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,529 people online right now. Registration is fast and FREE... Join Now!




keep getting incompatiable initializer on line 15 an 16

 
Reply to this topicStart new topic

keep getting incompatiable initializer on line 15 an 16

tnj107
13 Apr, 2008 - 08:09 AM
Post #1

New D.I.C Head
*

Joined: 5 Feb, 2008
Posts: 4

cpp

#include <stdio.h>

int get_currency_type(int);
float process_euros (float);
float process_yen (float);
float process_pesos (float);

int main(void){

int currency_type = 0;
float currency_amount = 0;
float dollars = 0;

currency_type = get_currency_type(currency_type);

switch (currency_type)
{
case 1:
printf ("\nInput amount of currency\n");
scanf ("%f", &currency_amount);
dollars = process_euros (currency_amount);
break;

case 2:
printf ("\nInput amount of currency\n");
scanf ("%f", &currency_amount);
dollars = process_yen (currency_amount);
break;

case 3:
printf ("\nInput amount of currency\n");
scanf ("%f", &currency_amount);
dollars = process_pesos (currency_amount);
break;

default:
printf("Incorrect value input, please try again\n");
return 0;
break;
}

printf ("\nThat is equal to $%.2f\n", dollars);

return 0;
}

int get_currency_type(int currency_type){
printf ("Input type of currency\n");
printf ("(1) Euros\n");
printf ("(2) Yen\n");
printf ("(3) Pesos\n");
scanf ("%d", &currency_type);
return (currency_type);
}

float process_euros(float currency_amount){
float dollars = 0;
dollars = currency_amount * 1.227;
return (dollars);
}

float process_yen(float currency_amount){
float dollars = 0;
dollars = currency_amount * 0.009031;
return (dollars);
}

float process_pesos(float currency_amount){
float dollars = 0;
dollars = currency_amount * 0.08760;
return (dollars);
}

*edit: Please use code tags in the future, thanks! code.gif


This post has been edited by Martyr2: 13 Apr, 2008 - 08:39 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Keep Getting Incompatiable Initializer On Line 15 An 16
13 Apr, 2008 - 08:39 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Well some compilers will let you get away with this but for you it appears your compiler is a stickler. I believe you need to set your floats "currency_amount" and "dollars" to use 0.0f instead of just 0. Remember they are floats meaning decimal point figures. Here we give it 0.0 but then we add the specifier "f" to also let the compiler know it is to be treated as a float value.

Let us know if that doesn't solve the problem. In that case show us your line 15 and 16.

smile.gif
User is offlineProfile CardPM
+Quote Post

tnj107
RE: Keep Getting Incompatiable Initializer On Line 15 An 16
13 Apr, 2008 - 08:55 AM
Post #3

New D.I.C Head
*

Joined: 5 Feb, 2008
Posts: 4

CODE
                                                          

int currency_type = 0;  
float currency_amount = 0;  
float dollars = 0;  
  
currency_type = get_currency_type(currency_type);  
  
switch (currency_type)  



this is the area that my miracle c compiler keeps saying incompatiable initializer. I have changed the 0 to 0.0f but it still does not compile???? I am so lost???
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 07:49PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month