Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2007, 07:45 AM
Member
 
Join Date: Dec 2007
Posts: 26
apfroggy0408 is on a distinguished road
Half a semester into java
I'm currently taking the APCS course at my school, and we've done some work with classes and such. I'm getting an error and I don't know how to resolve it. here's the code.

Code:
/** * @(#)WatchInterest.java * * * @author * @version 1.00 2007/12/11 */ import java.util.*; public class WatchInterest { public static void main(String args[]) { Scanner input = new Scanner(System.in); int choice; double principal; double yearlyInterest; int paybackYears; double monthlyPmt; System.out.println("Select on of the following options"); System.out.println(); System.out.println("[1] Monthly Loan Payment Computation"); System.out.println("[2] Amortization Schedule"); System.out.println("[3] Credit Card Pay-Off Schedule"); System.out.println(); System.out.println("Enter your choice: "); choice = input.nextInt(); System.out.println(); switch (choice) { case 1: System.out.println("Enter Loan Amount: "); principal = input.nextDouble(); System.out.println("Enter Annual Percent: "); yearlyInterest = input.nextDouble(); System.out.println("Enter Years to Pay Back: "); paybackYears = input.nextInt(); Interest loan1 = new Interest(principal, yearlyInterest, paybackYears,0); ---> loan1.computePayment(); break; case 2: System.out.println("Enter principle balance: "); principal = input.nextDouble(); System.out.println("Enter annual percent: "); yearlyInterest = input.nextDouble(); System.out.println("Enter monthly payment: "); monthlyPmt = input.nextDouble(); Interest loan2 = new Interest(principal, yearlyInterest, 0, monthlyPmt); loan2.amortization(); break; case 3: System.out.println("Enter credit card balance: "); principal = input.nextDouble(); System.out.println("Enter annual percent: "); yearlyInterest = input.nextDouble(); Interest loan3 = new Interest(principal, yearlyInterest, 0, 0); loan3.creditCard(); break; } System.out.println(); } } class Interest { private double principal; private double percent; private int years; private double monthlyPmt; private int months; private int pmtNr; private double monthlyRate; private double interestPmt; private double principalPmt; private double totalPmt; private double totalInt; public Interest(double la, double yi, int py, double mp) //do not alter anythign in the constructor { principal = la; percent = yi; years = py; monthlyPmt = mp; monthlyRate = percent/1200; months = years * 12; pmtNr = 0; } private double round(double x) { return (double) Math.round(100*x) / 100; } public void computePayment(double la, double yi, int py, double mp) { System.out.println(); System.out.println("Monthly Loan Payment Computation"); System.out.println(); totalPmt = ((yi*Math.pow((1+yi),mp))/(Math.pow((1+yi),mp)-1))*la; System.out.println("Loan Amount: " + principal); System.out.println("Yearly Interest: " +percent); System.out.println("Payback Years: " +years); System.out.println("Monthly Payment: " +monthlyPmt); System.out.println("Total Payments: " +totalPmt); System.out.println("Total Interest: " +totalInt); } public void amortization() { System.out.println(); System.out.println("Amortization Schedule"); System.out.println(); System.out.println("Loan Amount: " + principal); System.out.println("Yearly Interest: " + percent); System.out.println("Monthly Payment: " +monthlyPmt); do { System.out.println(pmtNr+" \t"+monthlyPmt+" \t"+interestPmt+" \t"+principalPmt+" \t"+principal); } while (principal > 0); System.out.println("Payback Months: " +pmtNr); System.out.println("Total Pyaments: " +totalPmt); System.out.println("Total Interest: " +totalInt); } public void creditCard() { System.out.println(); System.out.println("Credit Card Pay-Off Schedule"); System.out.println(); System.out.println("Yearly Interest: " +percent); do { System.out.println(pmtNr+" \t"+monthlyPmt+" \t"+interestPmt+" \t"+principalPmt+" \t"+principal); } while (principal > 0 ); System.out.println("Payback Months: " +pmtNr); System.out.println("Total Pyaments: " +totalPmt); System.out.println("Total Interest: " +totalInt); } }
The problem is occuring in the first switch case and the exact error is.

Code:
computePayment(double,double,int,double) in Interest cannot be applied to ()
Thanks for all help.

Last edited by apfroggy0408 : 12-13-2007 at 08:14 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-14-2007, 06:43 AM
Member
 
Join Date: Dec 2007
Posts: 1
ahmadmz is on a distinguished road
Hi, well the method computePayment requires 4 arguments and you are calling it with none.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-15-2007, 09:17 AM
Member
 
Join Date: Dec 2007
Posts: 26
apfroggy0408 is on a distinguished road
I'm not sure what you mean, but the problem was was that i was using the wrong variables.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-17-2007, 12:05 PM
Member
 
Join Date: Dec 2007
Posts: 32
felixtfelix is on a distinguished road
well. u have a method computePayment(double la, double yi, int py, double mp)in the Interest Class for which we have to send four parameters means four values as an arguments. But when you are calling the same method in the first switch statement u use the statement loan1.computePayment(). there we are not sending any parameters.

You can fix in two ways
1. Remove the parameters in the method definition inside the Interest class for all the methods.
2. Pass four parameters when you call the particular method in each of the switch class.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JAVA Architect Position - Robert Half Technology pegitha Jobs Offered 0 05-18-2007 10:40 PM


All times are GMT +3. The time now is 03:41 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org