Write a Logo procedure third :alist to output the 3rd item in a list. If the number of items in the list is less than three, it should just output the last item. Write similar procedures for 4th and 5th items. To check if a list is too short, you should use the built-in procedure count which outputs the number of things in a list. Also, recall that the Logo procedure first outputs the first item in a list, and the procedure bf (butfirst) outputs what remains. For example, first [ a b c d] is "a, and bf [a b c d] is [b c d]. Therefore, first bf [a b c d] is "b.
Write a Logo procedure convert :agrade which takes a letter (A, B, C, D, or F) and outputs a number (4, 3, 2, 1, 0).
Write a Logo program to process student GPAs.The input is the person's name (a list of up to 3 words) and the person's grades (five separate requests) for the last semester. For the name, you should not just write make "name readlist. Instead write a getname procedure that outputs a name only when it contains fewer than 4 words, and use make "name getname. To check if a list has at most 3 items in it, you can use Logo's built-in count command.
For example,
to getname
make "temp readlist
if ( < (count :temp) 4) then op :temp
pr [only three names at most please]
getname
end
You may assume that there are exactly five grades. You should, however, make sure that each grade is either A, B, C, D or F using a getgrade procedure instead of just using read. For example: make "gr1 getgrade make "gr2 getgrade etc.
The program should print out on the graphics screen: a nice colorful creative:
Welcome to Stonehill "person's first name".
Your grades for last semester were: ...
Your grade point average is: ...
Write the main procedure processgpa first and then fill in all the details later, using good top-down design style. Use helper procedures to help make your program simple to understand. You will need getgrade, getname, convert, and average. In particular, a procedure average :num1 :num2 :num3 :num4 :num5 will be useful, as well as the procedure convert :agrade from problem 2. For example: the last line of your program should be something like:
tt (se [Your grade point average is:] (average (convert :gr1) (convert :gr2) (convert :gr3) (convert :gr4) (convert :gr5)) )
4. Write a program that computes the GPA of a bunch of grades where you do NOT assume that there will be just 5 grades. You should ask the person how many grades there will be, and store the answer in “num_grades.
Then using repeat :num_grades [ ...], have the program repeatedly read a new score, and add it to a variable “mysum. At the end, you should divide :sum by :numgrades to print the average. Note that with this modification,
You no longer need the average procedure. You should use (/ :mysum :numgrades) instead.
You no longer need to print the grades out at the end. Only the gpa is printed.
You only need one variable "gr for reading the scores, and that variable gets reused each time for each subsequent new score.
Finally, note that you do NOT need to read all the scores in at once into a single list. (When you learn more about recursion, you will learn how to do this problem using a single list).