Data Structures II Homework 1 - Traffic Lights at Wentworth Institute of Technology, Assignments of Data Structures and Algorithms

Information about homework 1 for the data structures ii course offered by wentworth institute of technology's division of professional and continuing studies in fall, 2005. The assignment involves using an enum, enhanced for loop, and switch statement to sequence through trafficlight values and output their colors and associated messages from a file. Students are required to create a tab-delimited file named 'traffictext.txt' with messages and read them using the scanner class.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-9na
koofers-user-9na 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP385 Section 71 - Data Structures II - Fall, 2005
Homework 1 – Traffic Lights
Instructor: Bob Goldstein (617) 912-2512
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
enum TrafficLight{green, yellow, red};
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/2020

Partial preview of the text

Download Data Structures II Homework 1 - Traffic Lights at Wentworth Institute of Technology and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP385 Section 71 - Data Structures II - Fall, 2005

Homework 1 – Traffic Lights

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

enum TrafficLight{green, yellow, red};

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/