EXPLAIN HOW YOUR PROGRAM WORKS Write a program using WHILE loops. Use indentation well. O Provide helpful comments in the code. O Use variable names that give an indication of their use. O Ensure all variables have minimal scope When your program works, test it and check it ticks all the above boxes then have it assessed by a demonstrator. If you are having problems or don't understand the requirements ask for help. Train Count Write a program that is to be used to investigate how late trains passing through a given station are. The trains are so dire that virtually all trains seem to be running late. It should use a while loop to repeatedly ask the user to name the destination of the train that just departed. It should stop when the special code XXX is entered, and then give the total minutes late of all trains departed and which train was most punctual (ie least late). For example, one run might be as follows.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA

Write a literate version of the code
O EXPLAIN HOW YOUR PROGRAM WORKS
O Write a program using WHILE loops.
O Use indentation well.
O Provide helpful comments in the code.
O Use variable names that give an indication of their use.
O Ensure all variables have minimal scope
When your program works, test it and check it ticks all the above boxes then have it assessed by a
demonstrator. If you are having problems or don't understand the requirements ask for help.
Train Count Write a program that is to be used to investigate how late trains passing through a given
station are. The trains are so dire that virtually all trains seem to be running late. It should use a while loop to
repeatedly ask the user to name the destination of the train that just departed. It should stop when the special
code XXX is entered, and then give the total minutes late of all trains departed and which train was most
punctual (ie least late). For example, one run might be as follows.
What is the destination of the train that just departed? Liverpool
How many minutes late was it? 7
What is the destination of the train that just departed? Newcastle
How many minutes late was it? 1
What is the destination of the train that just departed? Southampton
How many minutes late was it? 5
What is the destination of the train that just departed? Taunton
How many minutes late was it? 3
What is the destination of the train that just departed? XXXX
The trains were in total 16 minutes late.
The most punctual train was to Newcastle. It was 1 minute late.
HINT: Have variables that store the most punctual train seen so far and its destination. If more than one train
is equally punctual you may choose either.
Make sure you comment your program with comments that give useful information, use indentation
consistently and that your variable names convey useful information.
Transcribed Image Text:Write a literate version of the code O EXPLAIN HOW YOUR PROGRAM WORKS O Write a program using WHILE loops. O Use indentation well. O Provide helpful comments in the code. O Use variable names that give an indication of their use. O Ensure all variables have minimal scope When your program works, test it and check it ticks all the above boxes then have it assessed by a demonstrator. If you are having problems or don't understand the requirements ask for help. Train Count Write a program that is to be used to investigate how late trains passing through a given station are. The trains are so dire that virtually all trains seem to be running late. It should use a while loop to repeatedly ask the user to name the destination of the train that just departed. It should stop when the special code XXX is entered, and then give the total minutes late of all trains departed and which train was most punctual (ie least late). For example, one run might be as follows. What is the destination of the train that just departed? Liverpool How many minutes late was it? 7 What is the destination of the train that just departed? Newcastle How many minutes late was it? 1 What is the destination of the train that just departed? Southampton How many minutes late was it? 5 What is the destination of the train that just departed? Taunton How many minutes late was it? 3 What is the destination of the train that just departed? XXXX The trains were in total 16 minutes late. The most punctual train was to Newcastle. It was 1 minute late. HINT: Have variables that store the most punctual train seen so far and its destination. If more than one train is equally punctual you may choose either. Make sure you comment your program with comments that give useful information, use indentation consistently and that your variable names convey useful information.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education