Question: 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




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: 1. Program should compile and run in order to be graded 2. You must use String formatters (i.e.printf(...)) for ALL output statements. Your solution should NOT contain the methods print() OR println( ). 3. 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: 4. a. Javadoc comments for the class b. Javadoc comments for each of the class' members (variables and methods) C. Comments for major steps in your code 5. 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. StepsToMiles - 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. b. TestStepsToMiles - This class contains the main method to perform unit testing on the previous class. Class StepsToMiles: a. Four variables: name (String), feet (double), and inches (double). b. Default constructor to initialize the variables to their default values - null for strings and -1 for numeric. C. Non default constructor to initialize the variables using the constructor's parameters. d. Accessors (setters) and mutators (getters) methods for all four variables - 6 methods in total. e. height_inches() returns the height in inches. Conversion: 1ft = 12 inches f. strideLength_inches() returns the length of a person's stride. Remember to invoke the previous method: stride = < < < height_inches >> X 0.413 g. miles (steps) returns the number of miles to walk given the desired number of steps. Remember to invoke the previous methods: miles = < > steps < 12 x 5280 h. currDate returns today's date as a String. One way is to use Java's GregorianCalendar to first extract the Month, Day, Year values, then build a string representing today's date. https://docs.oracle.com/javase/8/docs/api/java/util/Gregorian Calendar.html) i. format AsString: 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 TestStepsToMiles: Remember to show a message string before each prompt and use printf( ) ONLY a. Create an instance of class StepsToMiles using the default constructor. Use the mutator methods to assign values to the class' private members. See Figure 2 for a sample test. b. Prompt the user to enter a name and height in feet and inches. See Figure 2 for a sample test. These values will be used in the next step. C. Create a second instance of StepsToMiles using the non-default constructor. Use the values entered in the previous step. d. Using printf(): 1. Using the 1st instance, print today's as shown in Figure 2 2. Using the 1st instance, print the results of calling the function format AsString, pass the value 12345 for the steps parameter. 3. Using the 2nd instance, print the results of calling the function format AsString, pass the value 1000 for the steps parameter. Grading: Item Comments (Javadoc and major steps) PersonWeight class (Compiles and runs) 3 variables Accessor and mutator methods 2 Constructors heigth_Inches() stride Length_Inches( ) miles() TestPersonWeight class (Compiles and runs) Prompts 1st instance using default constructor 2nd instance using default constructor Today's date printf Correct output Points 10 3 6 10 5 5 5 10 5 10 5 16 10 100 Figures: < > Steps ToMiles (default package) name: String feet: double inches: double Steps ToMiles() Steps ToMiles(String, double,double) height_inches():double strideLength_inches():double miles(int): double getName(): String setName(String):void >getFeet():double >setFeet(double):void >getinches():double setinches (double):void formatAs String(int):String > currDate(): String Figure 1: Class Diagram -UML legend shown below Enter Name: John Doe Enter Height (ft and in): 6 1.1 Totay's Date: 9/6/2020 Name: Jane Doe Height: 5.00' 4.50" Stride: 26.64 Steps: 12,345 Walk: 5.19 miles Name: John Doe Height: 6.00 1.10" Stride: 30.19 Steps: 1,000 Walk: 0.48 miles < > TestSteps ToMiles (default package) TestSteps ToMiles() main(String[]):void Prompts for the 2nd instance. Prompts are right aligned Today's date. Label is right aligned Formatted output of the 1st instance which used the default constructor and hard-coded values. Labels are right aligned Formatted output of the 2nd instance which used the non-default constructor and the prompted values above. Labels are right aligned Figure 2: Sample Run UML Diagram Legend Symbol 4 1 4 A private member (i.e. variable or method) A private final member (i.e. variable) A public field (i.e. variable or method) A public abstract member (i.e. variable or method) A public constructor Description A static public member An interface A public class A public abstract class A hollowed arrow indicates inheritance An open-ended arrow indicates composition A dotted line and hollowed arrow indicate class implementation
Step by Step Solution
3.41 Rating (164 Votes )
There are 3 Steps involved in it
Create a java file StepsToMilesjava and TestStepsToMilesjava and copy the code to the files You can ... View full answer
Get step-by-step solutions from verified subject matter experts
