Long Assignment Help

Assignment Help: >> Data Types - Long

Long

Long is a signed 64 bit type and is useful for those occasions where an int type is not wide sufficient to hold the desired value. The range of a long is quite big. This makes it useful when bit, overall numbers are required. For instance, here is a program which computes the number of miles that lights will travel in a specified number of days.

// calculate distance light travels by using long variables.

Class Light {

Public static void main (String args [] ) {

int lightspeed;

long days;

long seconds;

long distance;

// around speed of light in miles per second

lightspeed = 186000;

days = 1000; // specify number of days here

second = days * 24 * 60 * 60; // convert to seconds

distance = lightspeed * seconds ;   // compute distance

System.out.print ("In" + days);

System.out.print ("days light will travel about") ;

System.out.println (distance + "miles.");

}

}

This program produces the output:

In 1000 days light will travel about 16070400000000 miles.

Clearly the conclude could not have been held in an int variable.

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