0

I am new to scheme, and are learning it using Dr.Scheme, please help

I came across this question, but have some trouble with it:
A clock structure (define-struct Clock(hours minutes seconds)). Make a function that Consume a Clock structure and output the total seconds


;;this is what i did
(define-struct Clock (hours minutes seconds))

(define Clock1(make-Clock 10 10 10))

(define (ChangeIntoSec ClockX)
(+ (+ (* (Clock-hours Clock1) 3600)
(* (Clock-minutes Clock1) 60))
(Clock-seconds Clock1)))

;;end
did I do it right? because is the user suppose to type in the hours, minutes and seconds themself in the interactive window? In my answer I made a clock myself, instead of asking the user to type in the time for the clock structure

please help

thanks in advance

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by fullmetal
0

The logic is right.
you don't need to go into nesting here.
this will work too
(+ (* (Clock-hours Clock1) 3600) (* (Clock-minutes Clock1) 60) (Clock-seconds Clock1))

Not sure what you meant by user interface.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.