I have been working on this program for the last three days and yesterday I some great help from this site. Thank you to those that helped me. But I have run into another brick wall.
Here is my current code. I have the display that I want, but I can't seem to get the sales that I input to go to the names in the display. Note: the function getaverage is still in the works.
PHP Code:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 6
/*======================================================*/
int getyn(char *msg);
int getcode(int *code);
double getsales(double *money );
void error(void);
void initcosts(char *ary);
void report(char ary[][7], double constant);
/*======================================================*/
/*======================================================*/
int main(void )
{
char name[6][7] = {"Larry", "Sue ", "Eva ", "Morley", "Pete"};
double totsales[6];
double sale, tot, avg;
int code, choice;
//initcosts(totsales);
do
{
printf("\n\t\tRocklin Realty\n\n\n");
code = getcode(name);
sale = getsales(totsales);
name[code][6] += sale;
choice = getyn("\nAnother");
tot += sale;
avg = (tot / 5);
}
while (choice != 'N');
printf("%.2lf\n\n", sale); // To check to see if it is printing the right amount
report(name, *totsales);
printf("\nTotal:%.2lf", totsales);
printf("\nAverage:%.2lf", avg);
return 0;
}
/*======================================================*/
/*======================================================*/
void getaverage(double *totsales, double *tot )
{
return;
}
/*======================================================*/
int getcode(int *code)
{
int key, err;
do
{
printf("\nPlease enter your code:");
scanf("%d%*c", &key);
err = (key < 1) || (key > 5);
if (err) error();
}
while (err);
return (key);
}
/*======================================================*/
double getsales(double *money )
{
double dollar;
printf("Please enter your sale:");
scanf("%lf%*c", &dollar);
return (dollar);
}
/*======================================================*/
int getyn(char *msg)
{
int c;
printf("%s (Y/N):", msg);
c = getchar( );
c = toupper(c);
return c;
}
/*======================================================*/
void error(void)
{
printf("\n\tYour code is invalid\n");
printf("\tPlease try another code");
return;
}
/*======================================================*/
void initcosts(char *ary)
{
int i;
for (i = 1; i < 6; i++ )
ary[i] = 0;
}
/*======================================================*/
void report(char ary[][7], double constant)
{
int i;
printf("Realtor\t\t\t\t\tTotal Sales\n\n");
for (i = 0; i < 5; i++)
{
printf("%s\t\t%22.2lf\n", ary[i], i);
}
}
/*======================================================*/
/*======================================================*/
Thank for the help it is greatly appreciated.