Change code in java program so that input of floating point

Assignment Help JAVA Programming
Reference no: EM13941974

Change code in Java program so that input of floating point values is possible.

/* Java program which outputs the average speed of an
*object given the distance and time travelled
* (speed = distance/time). */

// Java extension packages
import java.util.*; // import class
import java.io.*; // import class

public class AverageSpeed
{
// main method begins execution of Java application
public static void main( String args[])
{

Scanner input = new Scanner( System.in );

int Distance; // Number keyed in by user representing distance travelled
int Time; // Number keyed in by user representing time taken
int Speed; // Calculated average speed

// Takes input of number to be process representing distance travelled
System.out.print( "Please enter the distance travelled in kilometres: ");
Distance = input.nextInt();

// Takes input of number to be process representing travel time
System.out.print( "Please enter the time taken to cover the distance in hours : ");
Time = input.nextInt();

Speed = Distance/Time; // Calculates the average speed

// display the results calculated average speed
System.out.printf( "Your average speed per hour is: %dn" , Speed );

} // end method main
} // end class AverageSpeed

Reference no: EM13941974

Questions Cloud

The start of an election season two candidate with extreme : Suppose at the start of an election season two candidate with extreme positions are running against each other.  the median voter model predicts that each candidate will become more moderate because __________.
Rate of inflation expected to prevail for the next year : As of today, the rate of inflation expected to prevail for the next year is 0.2% in the U.S. and 0.3% in the euro zone. What is the expected change in the exchange rate S($/€) for the next year?
Assume that the fair value of the hall division : Assume that the fair value of the Hall division is $1,950,000 instead of $2,100,000. Prepare the journal entry to record the impairment loss, if any, on December 31,2013.
Write an expression for the signal : Write an expression for the signal, Sc, in terms of R, the coating blackbody emissive power, the blackbody emissive power of the surroundings, the coating emissivity, and the appropriate band emission fractions
Change code in java program so that input of floating point : Change code in Java program so that input of floating point values is possible.
Find the maximum gain-the maximum loss : Assume you buy a European put option on €125,000. The strike price is X($/€)=1.09, the maturity is one year, and the premium is 3 cents per euro. Find the maximum gain, the maximum loss and the break-even point S($/€). Use 4 decimals for the exchange..
Trying to remove a very tight bolt : Mechanics sometimes put a length of pipe over the handle of a wrench when trying to remove a very tight bolt. How does this help? (It is also hazardous since it can break the bolt.)
Discuss the potential influences of power : Write a summary in which you critically discuss the potential influences of power and politics that can affect your scenario organisation. Explain the issues of power and politics that may arise within and across teams as a consequence of the pend..
Analyzing the leadership of a 21st century : Using relevant theories and models critically evaluate and analyse the leadership of a 21st century business leader (must be an Australian or American leader).

Reviews

Write a Review

JAVA Programming Questions & Answers

  Give the definition of a class named doctor

Give the definition of a class named Doctor whose objects are records for a clinic's doctors.

  Good idea to test a general class with a driver program

Question 1: Why is it a good idea to test a general class with a driver program before trying to use it? Question 2: What is the difference between black box and glass box debugging?

  Create java program to describe inheritance and polymorphism

Create a Java program based on the geometric shapes example described at the beginning of this lesson using Classes Square, Triangle, Rectangle, and Circ leto help describe inheritance and polymorphism.

  How many states are there and draw and label the states

How many states are there and draw and label the states (with variable values) and transitions (with method names). Notice that all of the methods are total.

  Write and run a java program

Write and run a Java program which allows the user to input two doubles and outputs the greater of the two?

  How does an applet get loaded into the browser

How does an applet get loaded into the browser? What is needed in the APPLET tag to cause an applet to be loaded from a JAR file?

  Calculate the age of a person given the birthdate

Assemble a program to calculate the age of a person given the birthdate. The output should print the line "In 2014 you will be ''the age of the person" years old." Code needs to be in assembly language using motorola 68000.

  Palindrome is a sequence of char that reads backward forwrd

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that asks the user t..

  Javascript program that asks the use

Design a javascript program that asks the user for a username with at least eight characters, beginning with a letter and including at least one digit. Next, write a validation loop to ensure that these conditions have been met

  Extend the java defined hashmap class

Your goal is to extend the java defined HashMap class to add the ability to store multiple objects. To do this, you will edit MultiHashMap.java to both add new methods and override two methods from HashMap.

  Problem related to eclips

Goals: 1) Be able to work with individual bits in java. 2) Understand the serializable interface. 3) Understand the comparable interface.

  Client class to test implementation of the vector class

Write a client class to test your implementation of the Vector3D class thatyou implemented. Name the package in which this class is defined (projectname) vector3dapp.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd