Write a java program that inputs a price as a floating-point

Assignment Help Computer Engineering
Reference no: EM132134689

We use typecasting when we want to cast a value of one type to a value of another type.

Specifically, in this program, we want to convert a value of type double to a value of type int.

Recall that Java lets you assign a int value to a double variable, but not vice versa. To assign a double value to an int variable, you need to convince the Java compiler to trust you by explicit typecasting:

Write a Java program that

inputs a price as a floating-point value of type double, and then

separates and prints the dollar amount (an int) and the cent amount (another int) from the input value.

A sample run of your program should produce the following output, where the user's input is shown inredfor clarity:

Sample output:

Enter a Price : 248.75

the price is 248 dollars and 75 cents

Reference no: EM132134689

Questions Cloud

What is the probability that in the next six? flights : What is the probability that in the next six? flights, exactly four flights will be on? time?
Determine the probability of exactly four successes : Consider a binomial probability distribution with p=0.3. Complete parts a through c below.
Republican democrat independent : Suppose we know the following probabilities:
Extract the number of frames and frame size : For each frame number of blocks containing moving object are checked to satisfy H/W ratio depending on area covered by camera.
Write a java program that inputs a price as a floating-point : To assign a double value to an int variable, you need to convince the Java compiler to trust you by explicit typecasting.
What are the worst-case and best-case running times : We can sort a given set of n numbers by first building a binary search tree containing these numbers.
Create a menu form using form design view : Add three command buttons for the three forms in the database, and then add three command buttons for the three reports in the database.
Do you think sharing such details is a good approach : Do you think sharing such details is a good approach? Give arguments for both cases: "sharing details" and "not sharing details."
Develop a caesar cipher-type encryption algorithm : Develop a Caesar cipher-type encryption algorithm with a little more complexity in it.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Specification of tables-attributes

Handle costumes & accessories by using subtypes/supertypes, and show the ERD from all information we have gathered for the KCT. Your design should include a specification of tables, attributes, primary keys, foreign keys, data types, and null/not ..

  What is the future improvement and suggestion of cam design

Write a review paper of one mechanism we have learned this semester including its application, changes in design with time, and future direction.

  A paint calculator that gives the customer the area

Create a CustomerData.txt file with 10 Customers including Customers Name, Room Name, Length of the Room, Width of the room and Height of the room.

  Explore the considerations helpful when creating a terminal

explore the considerations useful when creating a terminal server farm including additional streams of business income

  Modify the stack directly or use the existing pop operation

To implement this operation, you could either modify the stack directly or use the existing Pop operation. What would be the advantages and disadvantages of each method?

  Discuss some of the information technology needs of health

write 400-600 words that respond to the following questions with your thoughts ideas and comments. be substantive and

  Define a formal information systems security plan

Effective information security recommendations must be incorporated into a formal information systems security plan

  Formalize the two interpretations of the rule on switching

Formalize the first of the two interpretations of the rule on switching the button off that were discussed in our assessment of the informal specification.

  Questiondeveloping requests specification for this

questiondeveloping requests specification for this integration. you have to use all of tools available to you to elicit

  Develop a uml class diagram diagram for a classic car

In this project, you have the opportunity to develop a UML class diagram diagram for a classic car museum database system.

  Provide characterization of when two distributions will have

In this exercise, we will provide a characterization of when two distributions P1 and P2 will have the same M-projection.

  Analyze household income survey data within cincinnati area

Create a project for a census bureau to obtain and analyze household income survey data within the Cincinnati area (including Northern Ky).

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