
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

COMP385 Section 71 - Data Structures II - Fall, 2005
Instructor: Bob Goldstein (617) 912- [email protected] http://webpages.charter.net/tlgcreations/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://public.wit.edu/~goldsteinr/index.html Due Date: September 13, 2005 Hand In: Printout of program code and dialogue of how it runs. Purpose: This homework is intended to use the enum facility, enhanced for statement and the Scanner class.. Description: This program is based on problem 1.10 of Ford and Topp Declare the enum
Using an enhanced for loop and a switch statement, sequence through the TrafficLight values and output the color of the light along with a message associated with each color. The messages are as follows: green – “SafeToGo” yellow – “ExerciseCaution” red = “StopImmediately” The messages should NOT be hardcoded into the program. The messages should be read from a file that you create. Make the file with the messages using a text editor (Notepad is ok), called trafficText.txt and read in the messages using the Scanner class. Here are the contents and format of the tab-delimited file: green SafeToGo yellew ExerciseCaution red StopImmediately Here is an output of the program. The program requires no user input: 3 color messages read into the program The values of the traffic lights and their meanings are: green SafeToGo yellow ExerciseCaution red StopImmediately /app/work/qkdb3l-473742-2765043-homework1-doc.doc 1 12/3/2020 12/3/