求各位大神指条明路

Game-Over 2014-03-25 11:20:54
car.java:33: error: constructor carloan in class carloan cannot be applied to given types;
carloan vn= new carloan(price, downpayment);
^
required: no arguments
found: double,double
reason: actual and formal argument lists differ in length
1 error

这个是我的error.

import java.util.Scanner;

public class car{
public static void main(String[] args){
double price;
double downpayment;
double interest;
int months;
int payment;

Scanner in= new Scanner(System.in);

System.out.print("Please enter the car price: ");
price=in.nextDouble();
System.out.println();

System.out.print("Please enter the amount of downpayment: ");
downpayment=in.nextDouble();
System.out.println();

System.out.print("Please enter the annual interest rate: ");
interest=in.nextDouble();
System.out.println();

System.out.print("Please enter the loan period in months: ");
months=in.nextInt();
System.out.println();

System.out.print("Please enter the number of payments you have paid: ");
payment=in.nextInt();
System.out.println();

carloan vn= new carloan(price, downpayment);

System.out.print("The amount borrowed is: "+ vn.getamountborrowed());
System.out.print("The monthly payment amount is: "+ vn.getmonthlyrate());
}}



public class carloan{
private double price;
private double downpayment;
private double interest;
private int months;

public double getamountborrowed(){
return price-downpayment;
}

public double getmonthlyrate(){
double P=price-downpayment;
double R=interest/12;
double B=1+R;
double C= Math.pow(B,months);
double D=R*C;
double E=C-1;
double F=D/E*P;
return price;
}}




我想知道为什么会出现这样的error.
...全文
279 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
aaronsuLoveM 2015-02-03
  • 打赏
  • 举报
回复
构造方法,setget方法。。。。没有传参数
tony4geek 2014-03-28
  • 打赏
  • 举报
回复
构造函数 参数
染指黄昏 2014-03-28
  • 打赏
  • 举报
回复
缺少构造函数 java基础再好好看看 照着列子敲
Jandison_lz 2014-03-28
  • 打赏
  • 举报
回复
no constructor
-江沐风- 2014-03-25
  • 打赏
  • 举报
回复
构造方法可以理解为是为了初始化数据,就是这样:
public carloan(double price,double downpayment)
	{
		this.price = price;
		this.downpayment = downpayment;
	}
学Java怎么会不知道构造方法呢?建议找本书看看,这是Java最基础的东西!
Game-Over 2014-03-25
  • 打赏
  • 举报
回复
引用 2 楼 zuoziji_lj 的回复:
[quote=引用 1 楼 u012724379 的回复:] 构造方法,你看一下! 没有构造方法,怎么传参数!
+1[/quote]大神可否说的再详细一些?我是个新手,没怎么接触过构造方法这个词。谢谢了
Game-Over 2014-03-25
  • 打赏
  • 举报
回复
引用 1 楼 u012724379 的回复:
构造方法,你看一下! 没有构造方法,怎么传参数!
大神可否说的再详细一些?我是个新手,没怎么接触过构造方法这个词。谢谢了
卡卡吉利 2014-03-25
  • 打赏
  • 举报
回复
引用 1 楼 u012724379 的回复:
构造方法,你看一下! 没有构造方法,怎么传参数!
+1
-江沐风- 2014-03-25
  • 打赏
  • 举报
回复
构造方法,你看一下! 没有构造方法,怎么传参数!
冰女潮汐 2014-03-25
  • 打赏
  • 举报
回复
建议楼主类名首字母大写吧

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧