Data type selection – CSKC
Sign In

Search

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.

Solution

TC++ #3873

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test Java

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.


Suggested Filename(s): BooleanType.java



Share

Created: 21-Mar-2018 13:38 | Updated: 21-Mar-2018 13:38|