Lab 5
Start Now

Overview

Write a "Surveyor's Assistant" to help a surveyor measure distances and angles along the surface of the ground.

Assignment

Write a programming to aid a surveyor in making measurements and entering them into the computer. Your program must display a menu of numbered options to the user. For example,

Welcome to the surveying program.  Please enter an option:
  1. Enter point 1
  2. Enter point 2
  3. Calculate the distance between the points
  4. Calculate the heading from point 1 to point 2
  0. Exit
Please enter the item you want: 2

The program should accept a numerical option from the user and perform the requested task. Upon completing the task, it should return to the menu. For example, if the user enters 3, the program should compute the distance between the two points and display the menu again.

Your program must include the following options:

Option: Enter numbers

The user must be allowed to enter the locations of the points, measured as meters north & east of a reference point (the origin). For example,

Entering point 1
Please enter the distance north (m): 4.5
Please enter the distance east (m): 2.4

After the user has entered a point, it should appear in the menu. For example, after entering point one,

Please enter an option:
  1. Enter point 1 (Currently 4.5 m N, 2.4 m E)
  2. Enter point 2
  3. Calculate the distance between the points
  4. Calculate the heading from point 1 to point 2
  0. Exit
Please enter the item you want: 2

Option: Calculate distance

The program should report the distance between the points to the user. See example program output at the end of the lab.

Option: Calculate the heading

The program should report the heading (degrees from north) of the ray extending from point 1 through point 2. For example,

Please enter an option:
1. Enter point 1 (Currently 0 m N, 0 m E)
2. Enter point 2 (Currently 1.7 m N, -1 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 4

The heading from (0 m N, 0 m E) to (1.7 m N, -1 m E)
is -30 degrees.

To measure an angle increasing positively from the x axis toward the y axis, use atan2(y2-y1,x2-x1). Note that x and y are different axis than you are using in your program. You should adapt this formula to apply to distances north and east, so that the angle is measured from north, increasing positively toward the east.

If the user attempts to calculate the distance or heading before entering the points, the program should professionally request the user to enter the points first. See the traces below for examples.

Option: Exit

When the user requests to exit, the program should print a farewell message and exit.

Requirements

  • The program must be created in a class named Lab5 that is in a package named the same as your MSOE username.
  • The program may use console or graphical input/output.
  • You must use a switch statement to manage the program menu.
  • Your program must format all decimal-part numbers using DecimalFormat with the format string "#.#"
  • Your program must not crash if the user enters valid input. The program should accept valid numbers for the point locations and any integer for the menu options. If the user enters an unexpected integer menu option, the program should report the error professionally and reprint the menu.

Lab Deliverables

See your professor's instructions for details on submission guidelines and due dates.
Dr. Dennis' class: See Blackboard
See Dr. Rebenistch for instructions
Dr. Taylor's class: See below
See Prof. Ung for instructions
Dr. Yoder's submission instructions
If you have any questions, consult your instructor.

Appendix 1: Example headings

This table gives example headings for a variety of input points:
Point 1Point 2 
N (m)E (m)N (m)E (m)heading (deg)
001.732-1-30
00-1.732-1-150
001145
00-11135
001-1-45
1100-135
10010090110135
102011.73219-30

Appendix 2: Example interaction

Welcome to the surveying program.  Please enter an option:
1. Enter point 1
2. Enter point 2
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: -1

Invalid option: -1.  Please enter the number of the menu item you want.

Please enter an option:
1. Enter point 1
2. Enter point 2
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 3

Please enter both points before using options 3 or 4. (Both
points are missing.)

Please enter an option:
1. Enter point 1
2. Enter point 2
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 1

Entering point 1
Please enter the distance north (m): 4.5
Please enter the distance east (m): 2.4

Please enter an option:
1. Enter point 1 (Currently 4.5 m N, 2.4 m E)
2. Enter point 2
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 2

Entering point 2
Please enter the distance north (m): 7.5
Please enter the distance east (m): -1.6

Please enter an option:
1. Enter point 1 (Currently 4.5 m N, 2.4 m E)
2. Enter point 2 (Currently 7.5 m N, -1.6 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 3

The distance from (4.5 m N, 2.4 m E) to (7.5 m N, -1.6 m E)
is 5 meters.

Please enter an option:
1. Enter point 1 (Currently 4.5 m N, 2.4 m E)
2. Enter point 2 (Currently 7.5 m N, -1.6 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 1

Entering point 1
Please enter the distance north (m): 0
Please enter the distance east (m): 0

Please enter an option:
1. Enter point 1 (Currently 0 m N, 0 m E)
2. Enter point 2 (Currently 7.5 m N, -1.6 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 2

Entering point 2
Please enter the distance north (m): 1.732
Please enter the distance east (m): -1

Please enter an option:
1. Enter point 1 (Currently 0 m N, 0 m E)
2. Enter point 2 (Currently 1.7 m N, -1 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 4

The heading from (0 m N, 0 m E) to (1.7 m N, -1 m E)
is -30 degrees.

Please enter an option:
1. Enter point 1 (Currently 0 m N, 0 m E)
2. Enter point 2 (Currently 1.7 m N, -1 m E)
3. Calculate the distance between the points
4. Calculate the heading from point 1 to point 2
0. Exit
Please enter the item you want: 0

Thanks for visiting.  Come again!

Acknowledgement

This laboratory assignment was developed by Dr. Josiah Yoder et. al.

Tuesday, 16-Feb-2016 10:54:08 EST