#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

int getline(char s[], int n){
int i,c;

for(i=0;i<n  && (c=getchar())!=EOF && c!='\n'; i++)
{
	s[i]=c;
}
s[i]='\0';
return i;
}



int lebege(char s[])
{

int ok=1,i=0,h,db=0;
float n=0;

h=strlen(s);

while(isdigit(s[i])) {i++; db++;}
if(db==0){ok=0;}

if(i!=h) {

if(s[i]!='.') {ok=0;}

i++;

while(isdigit(s[i])) {i++; db++;}
if(db==0){ok=0;}

if(i!=h) {ok=0;}

if(ok==1)
{n=atof(s);}

if(n<'1' && n>'2'){ok=0;}
else{ok=1;}

}

return ok;
}



int kaloriae(char kal[])
{
int h, i, ok=1, n=0;

h=strlen(kal);
for(i=0;i<=h;i++){
if(!isdigit(kal[i])){ok=0;}
else{ok=1;}
}

if(ok==1){
	n=atoi(kal);}

if(n<'1' || n>'2000'){ok=0;}
else{ok=1;}

return ok;
}





void main(void)
{
char s[128];
char etel[128];
char kal[128];

printf("\tKaloriaszamlalo program\n\n");

printf("Adja meg az etel nevet!\n");

getline(etel,128);


printf("Adja meg a mennyiseget [1-2], tort is:\n");

getline(s,128);

if(lebege(s)){printf("Jo\n");}
else{printf("Nem jo\n");}

printf("Adja 100g-jaban mennyi kaloria van: [1-2000]\n");

getline(kal,128);

if(kaloriae(kal)){printf("Jo");}
else{printf("Nem jo");}

}