Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93122154

Have any Question?


Related Questions in Computer Engineering

Describe the role of an ethical hacker and describe what

Describe the role of an ethical hacker and describe what you can do legally as an ethical hacker

Question suppose your network is using the stop and wait

Question Suppose your network is using the stop and wait protocol and it is really providing a slow service. You calculate the Utilization and it is 95.75%. Would getting faster Ethernet cards help speed up the network? ...

Given the following scenarios what is the standard

Given the following scenarios, what is the standard deviation for Acme, Inc.? Economy / Pri / Ri Strong / 0.3 / 40% Normal / 0.4 / 16% Weak / 0.3 / -20% Express your answer in decimal format (e.g., 0.1935 to represent 19 ...

A software engineering question regarding black-box testing

A Software Engineering question, regarding Black-Box Testing Techniques: Q:- A program computes its output variable T according to the following formula: [ x as in multiply] 1)T = X x 0.2 + Y x 0.4 + Z x 0.4 where X>= 50 ...

Create a class named horse that contains data fields for

Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field that hol ...

Question a show the results of inserting 10 12 1 14 6 5 8

Question : a) Show the results of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a into an initially empty binary heap. Show the tree at each stage. b) Show the result of performing three DeleteM ...

The richter scale is often used to measure the strength and

The Richter scale is often used to measure the strength and potential damage caused by an earthquake. Design and write an algorithm which accepts as input a Richter scale reading and then prints a message indicating the ...

In recreational mathematics a magic square is an

In recreational mathematics, a magic square is an arrangement of distinct numbers (i.e. each number is used once usually integers, in a square grid, where the numbers in each row and in each column, and the numbers in th ...

A different ethanol processing facility costs 800000 to

A different ethanol processing facility costs $800,000 to construct but will instead last forever. Every year (starting the year after  construction), it produces 10,000 barrels of ethanol and can charge a price of $4 pe ...

Suppose you have a singly-linked list of node objects with

Suppose you have a singly-linked list of Node objects with double data elements. The Node class is provided below. class Node { double data; Node next; } Consider that head is the reference variable that holds the starti ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As