Talk to your people! I got a question here on the internet to make it come out nothing at all. It asks for the following: Do you want to make a program that reads the name of the book that will be borrowed, the type of (student or teacher) and the book's loan date. The program should teacher has ten days to return the book and the student only five days. If any of them returns with delay, the program shall calculate the fine for that delay considering the amount of R $ 0.50 per day of delay The program should read the effective date of the return and at the end of the execution, it should print a receipt as shown below:
Book name: XXXXX
User Type: XXXXX
Loan date: XX / XX / XXXX
Due date of return: XX / XX / XXXX
Date of return: XX / XX / XXXX
Fine for delay: R $ XXX, XX
-Book Name: -User Type: -Date of loan: -Date of return: -Date of return: -Make it late:
My biggest problem is with the dates because I do not know how to operate them.
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<locale.h>
int main(){
setlocale(LC_ALL, "portuguese");
char usuario[10], livro[30];
int dia, mes, ano;
printf("Insira o nome do livro: ");
scanf("%s", &livro);
printf("Insira o tipo do usuário: ");
scanf("%s", &usuario);
printf("Insira a data do emprestimo: ");
scanf("%d%*c%d*c%d", &dia, &mes, &ano);
if((usuario[0]=='A')&&(usuario[1]=='L')&&(usuario[2]=='U'))
{
Nessa função "if" eu iria colocar um for para contar os dias de
atraso entre data de emprestimo e data da devolução, por exemplo:
dataemp=dataemp+5 //Pois alunos tem 5 dias para devolver
for(i = 0; dataemp<=datadev; i++)
multa = i * 0.50;
}
if((usuario[0]=='P')&&(usuario[0]=='R')&&(usuario[0]=='O'))
{
dataemp=dataemp+10 //Pois professor tem 10 dias para devolver
for(i = 0; dataemp<=datadev; i++)
multa = i * 0.50;
}
}
How can I get the user's date, subtract those dates, and add days to the date entered by the user? I read about time.h but I did not quite understand it to the point of implementing my code with it. Fuck, seriously, 4 days trying to do this and do not step from the algorithm I wrote above.