Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Data Structures I HW1 - Traffic Lights, Wentworth Institute of Tech, Spring 2007, Assignments of Data Structures and Algorithms

Information about the first homework assignment for the data structures i course offered by wentworth institute of technology in the spring of 2007. 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. The messages are stored in a tab-delimited text file called traffictext.txt.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-2hx
koofers-user-2hx 🇺🇸

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
COMP380 Section 71 - Data Structures I - Spring, 2007
Homework 1 – Traffic Lights
Instructor: Bob Goldstein (617) 912-2512
bobg@vision.eri.harvard.edu
http://webpages.charter.net/tlgcreations/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: January 23, 2007
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/qkd80q-459235-2765026-homework1-doc.doc 1 12/5/2020 12/5/2020

Partial preview of the text

Download Data Structures I HW1 - Traffic Lights, Wentworth Institute of Tech, Spring 2007 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP380 Section 71 - Data Structures I - Spring, 2007

Homework 1 – Traffic Lights

Instructor: Bob Goldstein (617) 912- bobg@vision.eri.harvard.edu http://webpages.charter.net/tlgcreations/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: January 23, 2007 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/qkd80q-459235-2765026-homework1-doc.doc 1 12/5/2020 12/5/