Computer science help

Discussion in 'OT Technology' started by nur23, Nov 29, 2006.

  1. nur23

    nur23 OT Supporter

    Joined:
    Jun 7, 2006
    Messages:
    487
    Likes Received:
    0
    Location:
    Chi-Town
    // Lab11st.java
    // The student version of the "Watch how you use interest" program.
    // This program computes loan payments, amortization and credit card pay-offs.

    import java.io.*;

    public class Lab11st
    {

    public static void main (String args[]) throws IOException
    {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int choice;
    double principal;
    double yearlyInterest;
    int paybackYears;
    double monthlyPmt;
    System.out.println("Select one 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.print("Enter your choice ===>> ");
    choice = Integer.parseInt(input.readLine());
    System.out.println();
    switch (choice)
    {
    case 1:
    System.out.print("Enter loan amount ===>> ");
    principal = Double.parseDouble(input.readLine());
    System.out.print("Enter annual percent ===>> ");
    yearlyInterest = Double.parseDouble(input.readLine());
    System.out.print("Enter years to pay back ===>> ");
    paybackYears = Integer.parseInt(input.readLine());
    Interest loan1 = new Interest(principal, yearlyInterest, paybackYears,0);
    loan1.computePayment();
    break;
    case 2:
    System.out.print("Enter principle balance ===>> ");
    principal = Double.parseDouble(input.readLine());
    System.out.print("Enter annual percent ===>> ");
    yearlyInterest = Double.parseDouble(input.readLine());
    System.out.print("Enter monthly payment ===>> ");
    monthlyPmt = Double.parseDouble(input.readLine());
    Interest loan2 = new Interest(principal, yearlyInterest, 0, monthlyPmt);
    loan2.amortization();
    break;
    case 3:
    System.out.print("Enter credit card balance ===>> ");
    principal = Double.parseDouble(input.readLine());
    System.out.print("Enter annual percent ===>> ");
    yearlyInterest = Double.parseDouble(input.readLine());
    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;
    private double round(double x)
    {
    x = x * 100 + 0.5;
    x = (double) (Math.floor(x)) / 100;
    return x;
    }

    public Interest(double la, double yi, int py, double mp)
    {
    principal = la;
    percent = yi;
    years = py;
    monthlyPmt = mp;
    monthlyRate = percent/1200;
    months = years * 12;
    pmtNr = 0;
    }

    public void computePayment()
    {
    System.out.println();
    System.out.println("Monthly Loan Payment Computation");
    System.out.println();
    }
    public void amortization()
    {
    System.out.println();
    System.out.println("Amortization Schedule");
    System.out.println();
    }
    public void creditCard()
    {
    System.out.println();
    System.out.println("Credit Card Pay-Off Schedule");
    System.out.println();
    }
    }




    I am absolutely stumped and have no idea how i'm supposed to complete this lab. :wtc:

    I really need help as to what exactly i'm supposed to do...do i use repetition?

    I'm supposed compute the monthly loan payment, amortization shedule and credit card pay-off schedule, but have no idea how.
     
  2. kilamasta

    kilamasta New Member

    Joined:
    Aug 14, 2006
    Messages:
    108
    Likes Received:
    0
    Maybe complete the classes so that they will do the operation written in the switch case?
     
  3. nur23

    nur23 OT Supporter

    Joined:
    Jun 7, 2006
    Messages:
    487
    Likes Received:
    0
    Location:
    Chi-Town
    sorry i don't understand what you're saying. :sadwavey:

    Can you explain in sort of a layman's term how to successfully get the monthly lona payment at least to calculate correctly?

    That and an explanation.
     
  4. HardTech

    HardTech hungry

    Joined:
    May 5, 2000
    Messages:
    28,103
    Likes Received:
    1
    Location:
    NorCal
    please use the
    Code:
     tags. It makes code much easier to read
     
  5. nur23

    nur23 OT Supporter

    Joined:
    Jun 7, 2006
    Messages:
    487
    Likes Received:
    0
    Location:
    Chi-Town
     
  6. HardTech

    HardTech hungry

    Joined:
    May 5, 2000
    Messages:
    28,103
    Likes Received:
    1
    Location:
    NorCal
    I mean in your post

    instead of

    if (OP == homosexual) {
    System.out.println("This is my post");
    }

    use the
    Code:
     tags
    
    [code]
    if (OP == homosexual) {
       System.out.println("This is my post");
    }
    
     

Share This Page