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

Username:   Password: 
 RegisterRegister   
 help plz
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Wed Feb 26, 2003 1:03 pm   Post subject: (No subject)

that sounds too much like a homework assigment

let me remind you that we will NOT do your assigments for you (unless you gonna pay us... send me an email then Wink)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
pheonix3000




PostPosted: Thu Feb 27, 2003 4:04 am   Post subject: (No subject)

Actually its not an homework assignment. i dont usually like to ask for the entire code cuz, what's the point of taking computer courses. neways, i tried to do a part of it and it goes something like this. it works but i want to round of the price. so that the ouput would be like $18.00. i tried a few things, but it kept giving me errors. also i would like to know how would i know that it is PM or Am when the time is given in 24 hr/.
code:

var day : string (9)
var rtime : real
var totalmin : real
var pass : string (1)
var Price : real

put "Please enter the day: "
get day
put ""
put "Please enter the time entered : "
get rtime
put ""
put "Please enter the total minutes parked :"
get totalmin
totalmin:=(totalmin / 60)
put ""
put "Do u have a pass? "
get pass

if day = "Monday" or day = "Tuesday" or day = "Wednesday" or day = 
"Thursday" or  day = "Friday" or day = "Saturday" then
Price := ((totalmin + rtime) / 2)  * 3.00
put "Price" :5 
end if

***ITS NOT AN HW assignment****
Tony




PostPosted: Thu Feb 27, 2003 5:58 am   Post subject: (No subject)

strange... I remember having a homework assigment just like this one Confused

anyway, you can round using round() or ceil(). 2nd one will round it up, so 0.1 will round to 1. floor() rounds down.

on a 24 hours system, 00 is midnight, 12 is noon and 24 is midnight again. Confused

So AM is 0 to 12 and PM is 12 to 24.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pheonix3000




PostPosted: Fri Feb 28, 2003 7:35 am   Post subject: (No subject)

While converting 111111 in to decimal the answer is 31. that is the input is an interget, but if the user enters a srting like "a" along with the binary numbers how would you code that?
pheonix3000




PostPosted: Fri Feb 28, 2003 7:35 am   Post subject: (No subject)

While converting 111111 in to decimal the answer is 31. that is the input is an interget, but if the user enters a srting like "a" along with the binary numbers how would you code that? Question
Tony




PostPosted: Fri Feb 28, 2003 7:59 am   Post subject: (No subject)

you can convert string to integer using strint()
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pheonix3000




PostPosted: Sat Mar 01, 2003 7:45 am   Post subject: (No subject)

i am not able to find the error. when u run it enter the data as
day : Monday
Time Entered : 9.00
Total mintues parked : 153
Pass: Y
and then next time put pass as N
when pass is no then the price should come out as $18.00 and when pass is "N' then then the price should come out as $8.50.
i am not able to get that.


var day : string (9)
var rtime : real
var totalmin : real
var pass : string (1)
var Price : real

put "Please enter the day: "
get day
put ""
put "Please enter the time entered : "
get rtime
put ""
put "Please enter the total minutes parked :"
get totalmin
put ""
put "Do u have a pass? "
get pass
if day = "Monday" or day = "Tuesday" or day = "Wednesday" or day =
"Thursday" or day = "Friday" or day = "Saturday" and pass = "N" then
totalmin := totalmin / 60
Price := round ( (totalmin + rtime) / 2) * 3.00
put "Price ", Price, ".00"
elsif day = "Monday" or day = "Tuesday" or day = "Wednesday" or day =
"Thursday" or day = "Friday" or day = "Saturday" or day = "Sunday"
and pass = "Y" then
Price := 8.500
put "Price ", Price
end if
pheonix3000




PostPosted: Sun Mar 02, 2003 11:34 pm   Post subject: (No subject)

i didnt get you on that strint () command. can u give me an example? it works fine when the user just enters the binary numbers, but as soon as the user enters a string with the binary numbers it gives an error.
ex. a01010.
what would be the decimal answer?
whereas for 111111 the decimal answer is 31.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Mar 03, 2003 12:28 am   Post subject: (No subject)

you should get rid of non numeric characters first. Ether an ifstatment inside a loop or you can use index().

I'm not sure on how it works, but I think that index("abcdefghijklmnopqrstuvwxyz",i) will return a an index value of any of those letters... so if its more then 0, then its an invalid input. You should check the syntax in turing help file though.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pheonix3000




PostPosted: Wed Mar 05, 2003 7:11 pm   Post subject: (No subject)

if u want to put the output statements in the horizontal order like this:

Day Time entered Minutes parked Pass Price
Mon 0900 153 N $18.00.


How would you do that? Confused
Tony




PostPosted: Wed Mar 05, 2003 7:32 pm   Post subject: (No subject)

ether with locate(row,column)

or

put name:10

where :10 means its 10 characters long so more spaces will be added to output to align

for floatpoint numbers its
num:2:10 where first :2 is number of decimal spaces and :10 as above
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pheonix3000




PostPosted: Mon Mar 17, 2003 6:26 pm   Post subject: (No subject)

case statements. how do u use the commands. like i sort of know how to do it, but i keep getting errors:

case "round" of
x := round (x)
put x
end case
end loop
Tony




PostPosted: Mon Mar 17, 2003 6:35 pm   Post subject: (No subject)

code:

case mark of
            label 9, 10 :   put "Excellent"
            label 7, 8 :        put "Good"
            label 6 :       put "Fair"
            label :     put "Poor"
        end case


so in your case Laughing

code:

case command of
            label "round":   x:= round(x)
end case
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dan




PostPosted: Mon Mar 17, 2003 6:40 pm   Post subject: (No subject)

that way to use case is:

code:

var mark:int

put "put in your mark(10-1): "..
get mark

case mark of
            label 9, 10 :   put "Excellent"
            label 7, 8 :        put "Good"
            label 6 :       put "Fair"
            label :     put "Poor"
end case


you whode not use the case statment the way you are. the case stame wroks a lot like the if but it takes a varible like mark in the expalem abouve and then compares it to other posiable vlauses and if it maches it runs the comands in that label.

for any one that cares the case stament in turing is much liike the swich stament in c & c++.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Dan




PostPosted: Mon Mar 17, 2003 6:40 pm   Post subject: (No subject)

dam, you posted befor me tony Crying or Very sad
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 2 of 3  [ 45 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: