Register
It is currently Mon Dec 22, 2014 12:45 pm

Need a script for calculator


All times are UTC - 6 hours


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Thu Dec 09, 2010 2:29 pm   

Joined: Thu Dec 09, 2010 2:18 pm
Posts: 3
i need a calculator script, which it can calculate even float numbers , and if its possible of course i want to make more than one operation at once
for example i want to calculate 5.6 + 2.3 / 6 * 7 .


Top
 Profile  
 PostPosted: Thu Dec 09, 2010 3:16 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
http://tinyurl.com/23vocv4


Top
 Profile WWW  
 PostPosted: Thu Dec 09, 2010 3:39 pm   

Joined: Thu Dec 09, 2010 2:18 pm
Posts: 3
yeah i have already read your page .
i have followed what you do exactly say .unfortunatly my teacher won't accept it because she insisted to write a script which it implements a calculator
i have done a script by my self but it doesn't allow to calculate float numbers and even the division opertion it didn't give the correct answer without commas

#!/bin/bash

echo -n "Enter a number:"

read n

echo "Calculations (x,-x, / x * x)"
echo "type = result without having to leave the calculator and proceed to do the calculation"
echo "type end to exit the calculator"
echo "======================================"
echo "==>"$ n
op = ""

while ["$ op" != "end"] do
while ["$ op ! =" = "] & & [" $ op " !=" end "] do
echo -n "==>"

read op





if ["$ op"! = "="] & & ["$ op"! = "end"];
Then
eval "let n = n $ op"



fi


done

if ["$ op" = "="];
Then

echo "$ n"
fi

if ["$ op" != "end"];
Then
echo -n "==>"
read op
eval "let n = n $ op"
fi
done
echo "======================================="
echo "$ n"


Top
 Profile  
 PostPosted: Thu Dec 09, 2010 5:17 pm   

Joined: Thu Dec 09, 2010 2:18 pm
Posts: 3
i resolved my problem.thank you anyway


Top
 Profile  
 PostPosted: Fri Dec 10, 2010 10:12 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
I usually use this one:
Code:
bc -l <<< '5^4/(3.23+1.010101)'


Top
 Profile  
 PostPosted: Thu Dec 30, 2010 2:00 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
guess we need to change this url to "comeaskushowtodobashhomework.org"...


Top
 Profile  
 PostPosted: Thu Dec 30, 2010 2:20 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 673
Location: Des Moines, Iowa
yeah, we have had a rash of those lately ;)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP