I'm trying to use this string
amountStr = amountStr.replace("$", "").replace(" ", "").replace(",", "");
but I get an error message which I know I'm getting because that string I just posted is outdated. So I was wondering what would be a good updated version of that string? here is how my whole code looks like.
import java.util.Scanner;
public class QuarterMachine{
/**
* Convert the input to cents.
*/
public static void main(String[] args){
// PART I INPUT SECTION (COMPLETE)
// DO NOT CHANGE THESE LINES
Scanner cin = new Scanner(System.in);
System.out.print("Part I-Enter the amount input ($ 1,572.52): ");
String amountStr = cin.nextLine();
// PLACE YOUR CODE ONLY BELOW THIS LINE
// PLACE YOUR OUTPUT IN THESE VARIABLES
// ---------- YOUR CHANGES HERE ----------------------
double amount = 0;
int quarters = 0;
//My problem is in line below
amountStr = amountStr.replace("$", "").replace(" ", "").replace(",", "");
amount = Double.parseDouble(amountStr);
quarters = (int) (amount * 100) / 25;
// PLACE YOUR CODE ONLY ABOVE THIS LINE
// PART I OUTPUT SECTION COMPLETE
System.out.printf("Amount received($%,.0f), quarters returned(%,d)%n%n",amount, quarters);
// PART II INPUT SECTION (COMPLETE)
System.out.print("Part II-Enter seconds, minutes and hours as integers: ");
int seconds = cin.nextInt();
int minutes = cin.nextInt();
int hours = cin.nextInt();
// PLACE YOUR CODE ONLY BELOW THIS LINE
// PLACE YOUR OUTPUT IN THIS VARIABLE
String result = String.format("%02d:%02d:%02d", hours, minutes, seconds);
// YOUR CODE MUST GO ABOVE THIS LINE
// PART II - OUTPUT SECTION COMPLETE
System.out.println("Result: " + result);
}
}