How many steps in a mile?
A steps‐to‐miles calculator determines the distance a person should walk in order to attain a specific number of steps. The formula is specific to every person and should be based on the length of their stride. A person’s stride is calculated based on their gender, height, and whether they are walking or running.
For this assignment we will implement a very simple walking steps to miles calculator using the formulas provided next.
Disclaimer: this assignment is only meant as a programming assignment and is not meant for any other purposes. Note:
- this is an individual assignment; please do your own work, sharing and/or copying code and/or solution ideas with/from others will result in a grade of 0 and disciplinary actions for all involved parties. If you run into problems and have done your best to solve them, please contact me before/after class or by e-mail.
- A 20% grade deduction for every day the assignment is late.
Assignment’s Requirements:
- Program should compile and run in order to be graded
- You must use 𝑆𝑡𝑟𝑖𝑛𝑔 𝑓𝑜𝑟𝑚𝑎𝑡𝑡𝑒𝑟𝑠 𝑖. 𝑒. 𝑝𝑟𝑖𝑛𝑡𝑓 … for ALL output statements. Your solution should NOT contain the methods 𝑝𝑟𝑖𝑛𝑡 OR 𝑝𝑟𝑖𝑛𝑡𝑙𝑛 .
- You should not need any 3rd party libraries (i.e. libraries besides Java’s API). If you think some libraries maybe useful, please check with me first.
- Comment your code:
- Javadoc comments for the class
- Javadoc comments for each of the class’ members (variables and methods)
- Comments for major steps in your code
- Submit two separate classes each in its own JAVA file. Please use Blackboard’s upload feature and don’t submit your compiled code or LINKS to online editors.
- 𝑆𝑡𝑒𝑝𝑠𝑇𝑜𝑀𝑖𝑙𝑒𝑠 – a container and operations class for the calculator. Follow the names shown in the UML diagram in Figure 1 exactly. I use a test script to examine your code which fails if you do not follow the naming convention.
- 𝑇𝑒𝑠𝑡𝑆𝑡𝑒𝑝𝑠𝑇𝑜𝑀𝑖𝑙𝑒𝑠 – This class contains the main method to perform unit testing on the previous class.
Class 𝑺𝒕𝒆𝒑𝒔𝑻𝒐𝑴𝒊𝒍𝒆𝒔:
- Four variables: 𝑛𝑎𝑚𝑒 (String), 𝑓𝑒𝑒𝑡 (double), and 𝑖𝑛𝑐ℎ𝑒𝑠 (double).
- Default 𝑐𝑜𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑜𝑟 to initialize the variables to their default values – null for strings and ‐1 for numeric.
- 𝑁𝑜𝑛 𝑑𝑒𝑓𝑎𝑢𝑙𝑡 constructor to initialize the variables using the constructor’s parameters.
- 𝐴𝑐𝑐𝑒𝑠𝑠𝑜𝑟𝑠 (setters) and 𝑚𝑢𝑡𝑎𝑡𝑜𝑟𝑠 (getters) methods for all four variables – 6 methods in total.
- ℎ𝑒𝑖𝑔ℎ𝑡_𝑖𝑛𝑐ℎ𝑒𝑠 returns the height in inches. Conversion: 1𝑓𝑡 12 𝑖𝑛𝑐ℎ𝑒𝑠
- 𝑠𝑡𝑟𝑖𝑑𝑒𝐿𝑒𝑛𝑔𝑡ℎ_𝑖𝑛𝑐ℎ𝑒𝑠 returns the length of a person’s stride. Remember to invoke the previous method:
- 𝑠𝑡𝑟𝑖𝑑𝑒 ≪ ℎ𝑒𝑖𝑔ℎ𝑡_𝑖𝑛𝑐ℎ𝑒𝑠 ≫ 413
- 𝑚𝑖𝑙𝑒𝑠 𝑠𝑡𝑒𝑝𝑠 returns the number of miles to walk given the desired number of steps. Remember to invoke the previous methods:
- 𝑚𝑖𝑙𝑒𝑠
- 𝑐𝑢𝑟𝑟𝐷𝑎𝑡𝑒 returns today’s date as a String. One way is to use Java’s 𝐺𝑟𝑒𝑔𝑜𝑟𝑖𝑎𝑛𝐶𝑎𝑙𝑒𝑛𝑑𝑎𝑟 to first extract the 𝑀𝑜𝑛𝑡ℎ, 𝐷𝑎𝑦, 𝑌𝑒𝑎𝑟 values, then build a string representing today’s date. https://docs.oracle.com/javase/8/docs/api/java/util/GregorianCalendar.html)
- 𝑓𝑜𝑟𝑚𝑎𝑡𝐴𝑠𝑆𝑡𝑟𝑖𝑛𝑔: receives one input for the numbers of steps and formats and returns the class’ members as a multi‐line string. Use the String format method to format and return the values as shown in Figure 2.
- All leading labels should have column widths of 13 characters
- All floating‐point numbers have precision 2 and the thousands comma (i.e. decimal separator)
Class 𝑻𝒆𝒔𝒕𝑺𝒕𝒆𝒑𝒔𝑻𝒐𝑴𝒊𝒍𝒆𝒔:
- Remember to show a message string before each prompt and use 𝑝𝑟𝑖𝑛𝑡𝑓 ONLY
- Create an instance of class 𝑆𝑡𝑒𝑝𝑠𝑇𝑜𝑀𝑖𝑙𝑒𝑠 using the 𝑑𝑒𝑓𝑎𝑢𝑙𝑡 Use the mutator methods to assign values to the class’ private members. See Figure 2 for a sample test.
- Prompt the user to enter a 𝑛𝑎𝑚𝑒 and ℎ𝑒𝑖𝑔ℎ𝑡 in 𝑓𝑒𝑒𝑡 and 𝑖𝑛𝑐ℎ𝑒𝑠. See Figure 2 for a sample test. These values will be used in the next step.
- Create a second instance of 𝑆𝑡𝑒𝑝𝑠𝑇𝑜𝑀𝑖𝑙𝑒𝑠 using the non‐default Use the values entered in the previous step.
- Using 𝑝𝑟𝑖𝑛𝑡𝑓 :
- Using the 1st instance, print today’s as shown in Figure 2
| pass the value 12345 |
- Using the 1st instance, print the results of calling the function 𝑓𝑜𝑟𝑚𝑎𝑡𝐴𝑠𝑆𝑡𝑟𝑖𝑛𝑔, for the steps parameter.
| pass the value 1000 |
- Using the 2nd instance, print the results of calling the function 𝑓𝑜𝑟𝑚𝑎𝑡𝐴𝑠𝑆𝑡𝑟𝑖𝑛𝑔, for the steps parameter.



