Question

Distance Walked Write a program to calculate how many mile, feet, and inches a person walks a day, given the stride length in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

import java.io.*;
import java.util.Scanner;
class walk
{
public static void main(String args[])
{
   final int Feet_Per_Mile = 5280;
   final int Inches_Per_Feet = 12;
   final int Inches_Per_Mile = Feet_Per_Mile*Inches_Per_Feet;
   int stride_length,avg_stride,minutes_walked,total_inches,total_feet,mile,inches;
   Scanner input = new Scanner(System.in);
  
   System.out.println("Enter the stride length in inches: ");
   stride_length = input.nextInt();
   System.out.println("Enter the average strides per minute: ");
   avg_stride = input.nextInt();
   System.out.println("Enter minutes walked: ");
   minutes_walked = input.nextInt();
   total_inches = stride_length*avg_stride*minutes_walked;
   total_feet = total_inches/Inches_Per_Feet;
   if(total_feet>=Feet_Per_Mile)
   {
       mile = total_feet/Feet_Per_Mile;
       total_inches = total_inches%Feet_Per_Mile;
       total_feet = total_inches/Inches_Per_Feet;
       total_inches = total_inches-total_feet*Inches_Per_Feet;
       inches = total_inches;
       System.out.println("Distance walked is "+ mile +" "+ "miles"+","+total_feet+" "+"feet"+","+"and"+" "+inches +" "+"inches");
   }
   else
   {
       mile = 0;
       total_feet = total_inches/12;
       total_inches = total_inches%12;
       inches = total_inches;
      
   System.out.println("Distance walked is "+ mile +" " + "miles" + " ,"+total_feet+" "+"feet"+","+"and"+" "+inches +" "+"inches");
   }
}
}

ca. Administrator: Command Prompt C:\Program Files\Java\jdk1.8.0_171\bin>java walk Enter the stride length in inches: 28 Ente

Add a comment
Know the answer?
Add Answer to:
Distance Walked Write a program to calculate how many mile, feet, and inches a person walks...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that contains the function measure() that is to accept a long integer number...

    Write a program that contains the function measure() that is to accept a long integer number total and the addresses of the integer variables inches, feet, yards, and miles. The passed long integer represents the total number of inches, and the function is to determine the number of miles, yards, feet, and inches in the passed value, writing these values directly into the respective variables declared in the calling function. This function will be called from the main program and...

  • For this Java program I have to be implementing a Pedometer class. The driver file will...

    For this Java program I have to be implementing a Pedometer class. The driver file will be provided for you ( PedometerDriver.java ) and can be downloaded in Canvas. Write a stand alone class. Name your class Pedometer and source file Pedometer.java . Program 6 Overview Goals Class and File Naming Here is the Unified Modeling Language (UML) diagram for the Pedometer class. See the end of this document for information on how to read a UML document. Pedometer -...

  • a C++ program that computes the cost of a long-distance call. The cost of the call...

    a C++ program that computes the cost of a long-distance call. The cost of the call is determined according to the following rate schedule: a. Any call started between 8:00 A.M. and 6:00 P.M., Monday through Friday, is billed at a rate of $0.40 per minute. b. Any call starting before 8:00 A.M. or after 6:00 P.M., Monday through Friday, is charged at a rate of $0.25 per minute. c. Any call started on a Saturday or Sunday is charged...

  • Question 12 pts The length of time a person takes to decide which shoes to purchase...

    Question 12 pts The length of time a person takes to decide which shoes to purchase is normally distributed with a mean of 8.21 minutes and a standard deviation of 1.90. Find the probability that a randomly selected individual will take less than 6 minutes to select a shoe purchase. Is this outcome unusual? Group of answer choices Probability is 0.88, which is usual as it is greater than 5% Probability is 0.12, which is usual as it is not...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT