Thread: Array troubles
View Single Post
  #1 (permalink)  
Old 10-04-2008, 05:50 PM
arctic_blizzard arctic_blizzard is offline
Newbie
 
Join Date: Oct 2008
Posts: 9
Credits: 0
Rep Power: 0
arctic_blizzard is on a distinguished road
Default Array troubles

Hi,
I am having trouble with one of my assignments dealing with arrays. The program requires a conversion between dollars and yen for a max number of 100 deposits.

The program needs to place user input ($) into an array, then convert those $ into Yen, and then display the value of each deposit in both dollars and yen.

I have completed the program basics, but am running into difficulties on several spots.

1). I get an error "invalid operands to binary" in my conversion sub-routine
2). I cannot figure out how to display the data needed.
3). I am sure there a few other things that I am missing - any help would be great!

Code:
#include <stdio.h>
const int MAX_CURRENCYS = 100;
const float DOLLARS_TO_YEN = 102.2;

    int nums;
    float Dollars;
    float Yen;

void readDollars ( float Dollars[], int count );
void DollarsToYen ( float Dollars[], float Yen[], int count );
void displayData ( float Dollars[], float Yen[], int count );
int main()
{        
    float Dollars[MAX_CURRENCYS],
           Yen[MAX_CURRENCYS];      

    int count;
    printf("\n Enter the number of Deposits: ");
    	scanf("%d", &count);

    readDollars (float Dollars[], int count);
    
    DollarsToYen (float Dollars[], float Yen[], int count);
    
    displayData (float Dollars[], float Yen[], int count);
    
    system("pause");

}

void readDollars (float Dollars[], int count)
{
   int j;
   printf("Enter the  dollar amount for each deposit: ");
   for ( j = 0; j < count; j++ )
       scanf("%d", &Dollars);
}
void DollarsToYen ( float Dollars[], float Yen[], int count )
{
    int j;
    for ( j = 0; j < count; j++ )
    Yen=(float)(Dollars*DOLLARS_TO_YEN);

}
void displayData ( float Dollars[], float Yen[], int count )
{
    int j;
    printf("\nDollars\tYen\n");
    for (j=0; j<count; j++)

    {
        printf("    %7f     %12f \n", j + 1);
    }
}
Reply With Quote

Sponsored Links