Example(s):Palindrome, prime, armstrong, "linear search", reverse etc.
Example(s):1575, 1632, 1539 (Only one at a time)
Login
[lwa]
Solved Problem
#JAVA#3873
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.
Solution
TC++ #3873
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
Notes
The above code can also be done with float type variables where f suffix would be required for literals.