Data type selection – Computer Sir Ki Class


Solved Problem #JAVA#3873    siteicon   siteicon  

Problem Statement - Data type selection

Write a program to initialise a variable with price of an item as a fractional value. Then prepare another variable to output the price multiplied with 100 so that its lowest currency denomination (LCD) value is achieved. Print the LCD price with a suitable message. Choose appropriate variable names and data types.


TC++ #3873

class SP_Price
public static void main(String[] args)
double price=230.50;
double lcd_price=price*100;
System.out.println("In lowest currency denomination of "+price+" would be "+lcd_price);

Test it !

Run Output

In lowest currency denomination of 230.5 would be 23050.0

double price=230.50;
Since it is a fractional value we select double as data type and price as the variable name

double lcd_price=price*100;
Another double data type lcd_price is initialised with price multiplied by 100

System.out.println(“In lowest currency denomination of “+price+” would be “+lcd_price);
It is suitably displayed


  • The above code can also be done with float type variables where f suffix would be required for literals.

Suggested Filename(s):


sunmitra| Created: 21-Mar-2018 | Updated: 21-Mar-2018|