Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hey prog can you help me?

Name: Anonymous 2011-04-07 18:44

this is my assignment:

1. Create a flowchart that represents the logic of the following problem:

The program asks the user to input five positive integer numbers, determines and displays the number of the even numbers and the average of these numbers. If the user inputs a number less than 10 or greater than 100, then asks the user to input another number until a valid e number is entered.  When the user enters five numbers, the program stops input and displays the number of the even numbers and the average of  all even input numbers. Use Raptor to create the flowchart and name file lab9. Test your flowchart.

2. Redo the problem 1 using Java. Name the file lab9.java.

i have no idea what to do! i've been working on this for an hour now but so far all i've done is make a loop counter!

i need your help! please

Name: Anonymous 2011-04-08 3:58

  (define (program)
    (define (input)
      (let loop ([n (read)])
        (if (and (integer? n) (>= n 10) (<= n 100))
            n
            (begin (displayln "Must enter an integer between >= 10 and <= 100")
                   (loop (read))))))
    (define (average l)
      (if (empty? l) 0 (/ (apply + l) (length l))))
    (displayln "Please enter five integers >= 10 and <= 100, separated with an enter.")
    (let loop ([l '()])
      (if (< (length l) 5)
          (loop (cons (input) l))
          (begin
            (display "Number of even numbers: ")
            (let count-loop ([l l]
                             [evens empty])
              (if (empty? l)
                  (begin (displayln (length evens))
                         (display "Average: ")
                         (displayln (exact->inexact (average evens))))
                  (count-loop (cdr l) (if (even? (car l))
                                          (cons (car l) evens)
                                          evens))))))))

Name: >>17 2011-04-08 4:00

Forgive me if it's a bit retarded... I'm still learning.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List