how do u solve this problem

I had this question after viewing Pascal Helo.

i had this script
unit hospital;
interface

implementation
uses crt;
Var
name:string;
typeofroom,tp,tv,nory1,nory2:char;
month, day, year, daysstayed,roomcharge,tpcharge,tvcharge,totalcharge:integer;

const
pc=125;
sc=95;
Wc=75;
Tvc=3.50;
Tpc=1.75;
begin
//prompting
writeln('please enter the patients''s name':44);
readln(name);
writeln('please enter the number of days stayed in the hospital':63);
readln(daysstayed);
writeln('please write the month':31);
readln(month);
writeln('please write the day':29);
readln(day);
writeln('pelase enter the year':30);
readln(year);
writeln('please enter y or n for which typeofroom you used. P for private, S for semi private, and W for ward':57);
readln(typeofroom);
Case typeofroom of 'P':roomcharge:=(pc*daysstayed);
                   's':roomcharge:=(sc*daysstayed);
                   'w':roomcharge:=(wc*daysstayed);
end;
writeln('enter y or n for yes or no if they used the telephone':62);
readln(nory1);
Case nory1 of 'Y':tpcharge:=(tpc*daysstayed);
                 'N':tpcharge:=0;
end;

writeln('enter y or n for yes or no if they used the television':63);
readln(nory2);
Case nory2 of 'Y':tvcharge:=Tvc*daysstayed;
                 'N':tvcharge:=0;
end;
//computing
Totalcharge:=roomcharge+tvcharge+tpcharge;


end.
and the error Error: Incompatible types: got "S80REAL" expected "LONGINT"
2 times
plz help me fix it
thanx
Dr anonymousAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
DISCLAIMER: I have ABSOLUTELY NO knowledge of Pascal.

Looks like a simple case of 'Numeric overflow' to me.

Why not just try to change from integer to longint and give it a go!

month, day, year, daysstayed, roomcharge, tpcharge, tvcharge, totalcharge : longint;

Open in new window


I am very well aware of the fact that it is an overkill!

Otherwise declare all your t? variables on a separate line with longint.

Also, are you sure none of the input are having decimal digits?
Dr anonymousAuthor Commented:
thanx dude. Ill try that
Geert GOracle dbaCommented:
why do you put :nnn at the end of the writeln ???

https://www.freepascal.org/docs-html/rtl/system/writeln.html

i can't ever remembering seeing that syntax
and i've worked with pascal since 1980

wont work with longint either.
because you are producing a real in some cases with multiplying with these consts
Tvc=3.50;
Tpc=1.75;

change the result vars in those variables to real
tvcharge, ...

btw, pascal is not C++, you don't need () all over
 's': roomcharge := sc * daysstayed;

Open in new window

works without the ( )

and to make it a little more userfriendly ... ignore the case

readln(typeofroom);
typeofroom := uppercase(typeofroom);
Case typeofroom of 'P': // ... roomcharge

Open in new window

PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Dr anonymousAuthor Commented:
anyone else with an solution?
Geert GOracle dbaCommented:
not a lot of people monitor the pascal group
i inserted the delphi topic
Geert GOracle dbaCommented:
i have a lot more solutions
but from the post I see, you are learning Delphi ... the good old fashioned way, starting from console

what other solution do you expect ?
G FCommented:
Simple question man... Tvc and Tpc are Real type. You must change the declaration from Integer to Extended or Real (if old Pascal version) to  the variables involved to multiplications and it will work fine..... I tried it and it was OK. Bye

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert GOracle dbaCommented:
Wow g f ... didnt i post that already ?
Dr anonymousAuthor Commented:
thx for contiruting
Geert GOracle dbaCommented:
The first was completely wrong, shouldn't have accepted that.
Dr anonymousAuthor Commented:
.....
G FCommented:
To I Read The Famous Manual.... You are right. Sorry
Geert GOracle dbaCommented:
G F did you close this question ?
G FCommented:
Closed.... Bye
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.