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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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