我正在尝试创建一个收取货币金额$ XX.xx的java程序,并输出更改的数量e-g季度,角钱,镍币等数量。
我无法将扫描程序从公共类传递给转换中使用的方法,然后在main方法中调用所述方法。
到目前为止,这是我的代码。
import java.util.Scanner;
public class moneyConverter{
double currentAmount = (int)(money *100.00); //variables
public static Scanner scan = new Scanner(System.in);
public static double money = scan.nextDouble();
public static void main(String[] args)
{
double money = 0.0;
money.Dollar();
money.Quarter();
money.Dime();
money.Nickel();
money.Penny();
}
public static void Dollar(Scanner scan){
double dollarAmount = scan.nextDouble() / 100.00;
double currentAmount = dollarAmount % 100.00;
System.out.println("Dollars: " +dollarAmount);
return;
}
public static void Quarter(Scanner scan){
double dollarAmount = scan.nextDouble() / 25.00;
double currentAmount = dollarAmount % 25.00;
System.out.println("Quarters: " +dollarAmount);
return;
}
public static void Dime(Scanner scan){
double dollarAmount = scan.nextDouble() / 10.00;
double currentAmount = dollarAmount % 10.00;
System.out.println("Dimes: " +dollarAmount);
return;
}
public static void Nickel(Scanner scan){
double dollarAmount = scan.nextDouble() / 5.00;
double currentAmount = dollarAmount % 5.00;
System.out.println("Nickels: " +dollarAmount);
return;
}
public static void Penny(Scanner scan){
double currentAmount = currentAmount;
System.out.println("Pennies: " +currentAmount);
return;
}
}
有人可以帮忙吗?
答案 0 :(得分:0)
attribute_id
是money
,它没有您尝试调用的方法。
通过执行以下操作来调用double
类中的方法:
moneyConverter