0
我正試圖編寫一個應用程序,輸入要打印在支票上的美元金額,我無法弄清楚如何在支票上打印出數字,並用****星號。檢查保護格式
這裏是我到目前爲止
import java.text.DecimalFormat;
import java.util.Scanner;
import java.text.NumberFormat;
import java.util.Locale;
public class CheckProtection
{
private static double maxAmount = 1000;
public static void main (String args [])
{
//System.out.printf(checkFormatter.format(check));
//DecimalFormat checker = new DecimalFormat("******.**");
//System.out.println(checker);
boolean validEntry = false;
while (validEntry == false)
{
Scanner userEntry = new Scanner(System.in);
System.out.println("Enter The check amount under a $1000.00 and greater that 0.");
if (userEntry.hasNextDouble() == true)
{
double check = userEntry.nextDouble();
if (check > 0)
{
if(check < maxAmount)
{
validEntry = true;
NumberFormat checkFormatter = NumberFormat.getCurrencyInstance();
checkFormatter.format(check);
System.out.printf("%5s",+ check);
}
}
}
}
}
我們需要的不僅僅是代碼轉儲。什麼是一些投入/預期產出/實際產出? – rmlan
輸入:3.54,525.43,72.50輸出:*** $ 3.54,** $ 525.43,*** $ 72.50, –