Question
Need this done is java program coding in the simplest way possible.
(Average speed in kilometers) Assume a runner runs 24 miles in 1 hour, 40 minutes, and 35 seconds. Write a program that displ
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi, PFB the code.

I am assuming that input is being provided via STDIN. Also I have attached the sample output screenshot. Please get back to me in case of any doubt and upvote if it was helpful.

import java.io.Console;
import java.util.Scanner;

public class HelloWorld{

public static void main(String []args){

Scanner input = new Scanner(System.in);
System.out.println("Please enter the distance travelled(in miles)");
double distance = input.nextDouble();
System.out.println("You entered "+ distance +" miles");
System.out.println("Please enter the time taken travelled(in hours, minutes & seconds respectively)");
distance = distance*1.6;
double hours = input.nextDouble();
double minutes = input.nextDouble();
double seconds = input.nextDouble();
  
  
System.out.println("You entered "+ hours +"hours "+ minutes+ " minutes"+ seconds+" seconds.");
  
double time_in_hours = hours + (minutes)/60.0 + (seconds)/3600.0;
double average_speed = distance/time_in_hours;
System.out.println("The average speed is "+ average_speed);
  
  
}
}$javac Hellolorld.java $java -Xmx128M -Xms16M Helloworld Please enter the distance travelled (in miles) You entered 24.0 mile

Add a comment
Know the answer?
Add Answer to:
Need this done is java program coding in the simplest way possible. (Average speed in kilometers)...
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 displays the following pattern: Write a program that displays the following table:...

    Write a program that displays the following pattern: Write a program that displays the following table: Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. Write a program that displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers) The U.S. Census Bureau projects population based on the following assumptions: One birth every 7 seconds One death every 13 seconds One new immigrant every 45 seconds Write a program to display the...

  • A car travels 40 miles in 30 minutes. a. What is the average velocity in kilometers/hour?...

    A car travels 40 miles in 30 minutes. a. What is the average velocity in kilometers/hour? b. If the car weighs 1.5 tons, what is its kinetic energy in joules (Note: you will need to convert your velocity to m/s)? c. When the driver applies the brake, it takes 15 seconds to stop. How far does the car travel (in meters) while stopping? d. What is the average acceleration of the car (in m/s2) during braking?

  • 1 of 2) Calculate the speed, C, (in meters per second) of a tsunami with a wavelength of 180,000 meters (180 kilometers or112 miles) and period of 15 minutes traveling over the Pacific (which has an a...

    1 of 2) Calculate the speed, C, (in meters per second) of a tsunami with a wavelength of 180,000 meters (180 kilometers or112 miles) and period of 15 minutes traveling over the Pacific (which has an average depth of 4000 meters (4 kilometers or 2.5 miles). Round up your answer so that there is no decimal. Note that the answer is not 200 m/s as it is incorrect 2 of 2) Using the speed of the tsunami that you calculated...

  • Need help coding with Java. Explanation in code would be greatly appreciated. Thanks Bar graph 2.0...

    Need help coding with Java. Explanation in code would be greatly appreciated. Thanks Bar graph 2.0 Write a program that accepts a list of up to 100 integers and displays a bar graph showing the frequencies of the values and the corresponding percentage frequency distributions (printed to 1 significant digit). Example runs are shown below. Number of values to graph: Enter the integer values separated by a space: Bar graph for 3 #1111# 01110 100.01 umber of integers to readi...

  • Java (Please answer in a specific way and not just show the program) Determine the largest...

    Java (Please answer in a specific way and not just show the program) Determine the largest values of n for which the corresponding Fibonacci Numbers can be computed within the given time. n = _____ time required: less than 10 seconds n = _____ time required: less than 30 seconds n = _____ time required: less than 1 minute n = _____ time required: less than 5 minutes Estimate the value of n for the largest value of fib(n) that...

  • Need some assistance of reorganizing this whole program. I have the right code for everything I...

    Need some assistance of reorganizing this whole program. I have the right code for everything I just need help on putting all the codes in the right spot so it can come out to the correct output. output is supposed to look like this: 1 \\ user inputs choice to convert 12 to 24 8 \\ user inputs 8 for hours 30 \\ user inputs 30 for minutes 20 \\ user inputs 20 for seconds AM \\ user inputs AM...

  • Java Programming. Please make sure program compiles, the code is copyable, and screenshots of the output...

    Java Programming. Please make sure program compiles, the code is copyable, and screenshots of the output are provided for 5 stars :-) Calculation for speed is just supposed to be google searched 1) 18 points] You've been hired by Pedal Punchers to write a Java console application that estimates bicycle speed in miles per hour. Use a validation loop to prompt for and get from the user the wheel diameter of a bicycle in inches in the range 10-50. Then...

  • Java Programming The program template represents a complete working Java program with one or more key...

    Java Programming The program template represents a complete working Java program with one or more key lines of code replaced with comments. Read the problem description and examine the output, then study the template code. Using the problem-solving tips as a guide, replace the /* */ comments with Java code. Compile and execute the program. Compare your output with the sample output provided. Modify class Time2 to include a tick method that increments the time stored in a Time2 object...

  • 26/ Only calculate the speed of the segment A, B, C suddenly you sawa s later...

    26/ Only calculate the speed of the segment A, B, C suddenly you sawa s later you heard the air is about 340 m/s us system can prop- stimate the time it Time, t (s) ur finger touches a FIGURE 2-25 Problem 23 per hour s tortoise, which r 1.2 minutes the flight in the same hat was the aver- val? 24. . The position of a particle as a function of time is given by x (-5 m/s)t +...

  • Project overview: Create a java graphics program that displays an order menu and bill from a...

    Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...

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