Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help Please Just Need To Round
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
riptake13




PostPosted: Sat Oct 24, 2015 2:57 pm   Post subject: Help Please Just Need To Round

What is it you are trying to achieve?
trying to round the numbers


What is the problem you are having?
Can not find the proper command

Describe what you have tried to solve this problem
Used the rounding commands floor and ceil but I need the numbers to round to 2 decimal place


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
floor and ceil commands

[/syntax]
var tree: int
var sum:= 0
var sum2 := 21
var sum3 : int
var sum4:= 0
var discount: int
discount:= 0
var hst: int
% a:= 4 div 3
% if 4 rem 3 not = 0
% a:= a +1
% end if

put " How many trees do you want cut down"
get tree
var stump : array 1..tree of int
var height : array 1.. tree of int
for x: 1.. tree

put " What is the height of the #", x , " tree (nearest foot, round up) "
get height (x)
if height(x) < 10 then
sum:= sum+ 350
elsif height(x)> 10 and height(x)<28 then
sum:= sum + 600
elsif height(x)< 50 and height(x)>=28 then
sum:= sum + 1300
else
%1602
put ""
sum := sum + 1800
cls
end if
end for

for y: 1.. tree
put " What is the stump width of the #", y , " tree (nearest inch, round up) "
get stump(y)

if stump(y) <= 10 then
sum2:= sum2
elsif stump(y) > 10 then

sum2 := sum2 + 4
end if
end for
sum3:= sum2 + sum
delay(350)
cls

if sum3 > 1200 then
put " You are elegibale for a 12% discount from our company"
discount:= ceil (sum3 * 0.12)

sum3:= sum3 - discount
put " Your subtotal is now,$", sum3:4:2

else
put" You subtotal is,$", sum3:4:2
end if
delay(2500)
cls

hst:= ceil (sum3 * 0.13)
sum4:= sum3 + hst

put"Subtotal: $", sum3
put"Discount: $", discount
put"Subtotal after discount: $", sum3
put"HST: $", hst
put"Total: $", sum4

Please specify what version of Turing you are using
??? Downloaded the newest one from this site
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Oct 25, 2015 6:41 am   Post subject: RE:Help Please Just Need To Round

There is no command to round to two decimal places, but with the round() command and a little bit of math it can be done.
riptake13




PostPosted: Sun Oct 25, 2015 8:55 pm   Post subject: Re: RE:Help Please Just Need To Round

Insectoid @ Sun Oct 25, 2015 6:41 am wrote:
There is no command to round to two decimal places, but with the round() command and a little bit of math it can be done.




Got it, just need to multiply the number by 100 then divide by 100 and round.

.... couldn't of you just told me that?

but thanks
Insectoid




PostPosted: Mon Oct 26, 2015 12:10 pm   Post subject: RE:Help Please Just Need To Round

Quote:
couldn't of you just told me that?


But the fun part is figuring it out yourself!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: