Please check : )

#include <stdio.h>
#include <stdlib.h>
include<time.h>

struc display{
int month;
double interest rate;
};

void displays(FILE*displayR)
lf calculate()
int enterOption(void)

int main()
{
char userName[20];
FILE*dislay;
int options;
time_t current=time(NULL);
struct tm*t=localtime(&current);
char date[30];
char currTime[30];
strftime(date,sizeof(date),"DATE: %b %d %Y",t);
strftime(currTime,sizeof(currTime),"TIME: %H:%M:%S",t);

printf("**************************\n\n"
"//logo\t\t\t\tWelcome to MSYBank\n\n"
"\t\t\t\t\t\t%s\n%s\n"
"**************************",date,currTime\n\n);

printf("Hi, what is your name? ");
scanf("%[ A-Z a-z ]s \n",&userName);
system("cls");

printf("Welcome to MSYBank, %s !\n",userName);
printf("Please select your option: \n");

if(display=fopen("display.txt","w"))==NULL)
{
printf("File could not be opened.\n");
}
else
{
while((options=enterOptions())!=3)
{
switch(options)
{
case 1:
display();
break;
case 2:
calculate();
break;
case 3:
system("cls");
print("TQ visiting. have a nice day!^^");
default:
printf("Incorrect options\n");
break;
}
}

fclose(display);
}
return 0;
)

void displays(FILE*displayR)
{
FILE*displayW;

struc display={Tenor(months),interestRate};

if((displayW=fopen("displays.txt","w"))==NULL)
{
printf("File could not be opened.\n");
}
else
{
rewind(displayR);
fprintf(displayW,"%-6d%-16lf\n","Tenor","interestRate");

while(!feof(displayR))
{
fread(&client, sizeof(struct diplays),1,displayR);

if(display!=0)
{
fprintf(displayW,"%-6d%-16lf\n",Tenor,interestRate);
}
}

fclose(displayW);
}
}

lf calculate()
{
double deposit;
int month;

if (month ==1&&deposit>=5000)
{
printf calculate();
}
else if(month>=2&&month<=60&&deposit>500)
{
printf calculate();
}
else
{
printf("invalid input!! Please enter again.");
}
}

int enterOption(void)
{
menuOptions;
printf("Here are your options\n\n"
"\tOptions\t\tFunction\n"
"\t1\t\tDisplay Interest Rate\n"
"\t2\t\tCalculate Interest Earn\n"
"\t3\t\tExit\n\n"
"Please select your option.\n");

scanf("%d"menuOption);
return menuOptions;
}




I couldn`t run it, wonder what`s wrong >< please check for me..
Compiler messages are usually a godsend. Try posting the errors your compiler gave. Also, use the <> button to wrap your code in code tags. It will make helping you a lot easier.

Some things I noticed:
-I don't think you can write string literals on separate lines like:
1
2
printf("Hello "
   "There");

-You are missing a comma on your last scanf() call.
-I don't understand what you are trying to do with:
 
printf calculate();
-I don't think you can write string literals on separate lines like:


You actually can do this. Adjacent string literals are automatically combined (at least on gcc).
Uhm.. printf calculate("InterestRate.txt"); should be this, forgot to type it in.. So, for the string literals- I have to type them all to a single line? :O

Errors:-
-Expected '=',',',';' 'asm' or '_attribute_'before '<' token
-ISO C does not allow extra ';' outside of a function
-In function 'displays':
-Expected declaration specifiers before 'if'
-stray '\' in program
-stray '\' in program

Screenshot of the errors: (Just in case I missed out something above)
http://prntscr.com/1cjytp
http://prntscr.com/1cjyv2
Last edited on
Thanks for clarifying firedraco. And no, Sunli, you don't have to type it all on one line. I was wrong.

Following the error messages:
1) The first error is pretty blatant now that I see it. You forgot "#" on the third include.
2) When you defined your struct, you missed the "t" at the end of the keyword.
3) On two lines, you have "If calculate()" which makes no sense. If this is supposed to be one name, then you need an underscore: "If_calculate()." Plus, the compiler only caught this error because you forgot your semi-colons in your prototypes, so it thought the first "display" was the function definition and not a prototype.
4) In your first call to printf, your last variable is "currTime\n\n," which also makes little sense. Your variable is currTime, and if you wanted a new line, you should have put that inside the string literal and not the variable, i.e. "\t\t\t\t\t\t%s\n%s\n\n\n"/*...*/, date, currTime);

You should be looking over your code more carefully before asking for help. Some of the errors were due to typos which you would have been able to spot easily.
Last edited on
Uhmm thanks, I did noticed I forgot to put '#' on third include and the 't' for struct after posting the errors :x I`ll try to fix it and see if there`s still any errors, thanks daleth :)
Topic archived. No new replies allowed.