Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In this code can I make the number and operation in one line such as 22+3/5=:confused:
and I want introduction, Purpose and conclusion :rolleyes:

program calculator_in_pascal;
var
   x : integer;
   num1 , num2 , ms , amo : real;
   ope , ord : char;
   cho : string;
begin
   num1 := 0;
   x := 0;

                  { calculator program }
   writeln();
   writeln(' ______________________________________________________');
   writeln('| After each Number or Operation, Please press <Enter> |');
   writeln('|______________________________________________________|');
   Readln(num1);
   while x < 1 do
   begin
   Readln(ope);
   if ope = '+' then
   begin
      readln(num2);
      num1 := num1 + num2;
   end         {addition}
   else if ope = '-' then
   begin
      readln(num2);
      num1 := num1 - num2;
   end         {Subtraction}
   else if ope = '*' then
   begin
      readln(num2);
      num1 := num1 * num2;
   end         {Multiplication}
   else if ope = '/' then
   begin
      readln(num2);
      num1 := num1 / num2;
   end        {division}
   else if ope = '=' then
   begin
      writeln(num1:0:9);
      writeln();
      writeln('select 1- for Continue OR 2- for Exit');
      readln(ord);
      if ord = '1' then
          begin
          continue;
          end
      else if ord = '2' then
          begin
          break;
          end;
   end;
   end;

   writeln();
   writeln();
   writeln('press <Enter> to Quit');
   readln();
end.


thanks everyone:rose:
Posted
Updated 30-Dec-10 2:09am
v3
Comments
Estys 30-Dec-10 7:55am    
That's a very bad calculator :-)
What's the question?
Sandeep Mewara 30-Dec-10 10:13am    
Update from OP:
if I writen this introduction

This was very simple calculator in pascal application. Where user can provide input for real numbers. Whenever the user wants to do some mathematical operations, just use the keyboard to do the calculations. And should press "enter" after each number and operation. For know the result should enter equal sign. then choosed 1 for continue or 2 for exit.
is good and complete??

We don't do people's homework for them. It's not because we think it's beneath us, but because if YOU don't do it yourself, YOU won't learn anything.

 
Share this answer
 
v2
Comments
Slacker007 30-Dec-10 13:42pm    
Good answer +5 to counter the one vote
This person thinks that you've got yourself a calculater that doesn't even consider operator precedence. Applied to input 22+3/5 the outcome
is
Pascal
writeln(((22+3)/5));

which is quite different from:
Pascal
writeln((22+(3/5)));

That's what I think!

Cheers,

Manfred
 
Share this answer
 
Comments
LloydA111 30-Dec-10 10:48am    
I left that part for him to do :)
Manfred Rudolf Bihy 30-Dec-10 12:31pm    
I'm sorry Lloyd, I didn't intend to mess with your OP education policy! :-D
Yes.

writeln(22+3/5);
 
Share this answer
 
Comments
Estys 30-Dec-10 8:09am    
What's the Purpose?
LloydA111 30-Dec-10 10:47am    
It outputs the answer to your question?
LloydA111 30-Dec-10 10:49am    
*the OP's question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900