samedi 11 janvier 2020

Comparing variables within Racket?

I am trying to create a function that asks for user input for multiple integers, and then outputs the least greatest of the variable. (For ex. 1, 4, 67 for inputs would result in 1.)

I tried requesting each integer separately and storing them as variables, but then am having issues in establishing a good if then else statement that would print int1, int2, or int3 depending on which is the least greatest.

#lang typed/racket
(require typed/test-engine/racket-tests)
(require "../include/cs151-core.rkt")
;; The necessary .rkt files...


(printf "Enter your first integer: ")
;; Requests user input for first variable
(define int1 (read-line))
;; Stores user input in variable int1
(printf "Enter your second integer: ")
;; Requests user input for second variable
(define int2 (read-line))
;; Stores user input in int2 variable
(printf "Enter your third and final integer: ")
;; Requests user input for third variable
(define int3 (read-line))
;; Stores user input in third variable int3


; (define (int-sorter int1)
;   (cond
;     [(< int1 int2)
;      (display int1)]
;     [(> int1 int2)
;       (cond
;         [(< int2 int3)
;          (display int2)]
;         [(display int3)])]))

Aucun commentaire:

Enregistrer un commentaire