Edit: Ah, never mind. I feel silly. I just needed to convert amount into an integer.
I am having a little trouble figuring out how to assign a variable (dollars) to the numbers left of the decimal and how to assign a variable (cents) to the right of the decimal. The only parts of the code I can modify are those 2 assignment statements because it is a homework question. The user inputs something like 123.45
Thanks for any help.
I am having a little trouble figuring out how to assign a variable (dollars) to the numbers left of the decimal and how to assign a variable (cents) to the right of the decimal. The only parts of the code I can modify are those 2 assignment statements because it is a homework question. The user inputs something like 123.45
Thanks for any help.
Code:
import java.util.Scanner; public class ApplicationSkel { public static void main(String[] args) { double amount; int dollars, cents; Scanner scan = new Scanner(System.in); System.out.print("Enter your purchase $"); amount = scan.nextDouble(); [B]dollars = ________; cents = ________;[/B] System.out.print("You entered " + dollars + " dollars and " + cents + "."); } }
Comment