mortgeage calculator help

Here is my code for the mortgage calculator. Please look over it and tell me where I am going wrong. The third and last lines is where I get my errors tell, what is needed.

import java.io.*;

import static java.lang.Math.*;

public class keyin.java //Class for input streams into your code <'{' expected

{

public static String readln()

{

StringBuffer resp = new StringBuffer();//resp for user response

try // This is a form of error trap - in tells the compiler to "try" the code

{

BufferedInputStream keybuff = new BufferedInputStream(System.in); //key buffer

int ks = 0; //initializing the key stroke variable

char keyChar;

do //start of a do while loop for building the input string

{ //This code block is capturing characters from the KB and appending

//them together

ks = keybuff.read();

keyChar = (char) ks; // notice the type cast (char) since keyboarding

if (ks != -1)// is really one character at a time

{// the keycode integers are type cast into characters for appending

resp.append(keyChar);

}

}

while ((ks != -1) & (keyChar != '\n')); //breaks the loop if the enter key is hit

keybuff.close();

return resp.toString();

}

catch (IOException e) //this is the second part of an error trap that catches the error

{ // from the try block of code

System.out.println("Exception: " + e.getMessage());

return null;

}

}

public static void main(String[] arguments)//Sample used to get loan amt

{

Double tempAmt; //Object type to convert string value

Double tempYears;

double loanYears;

double amtPrin; // Original Loan Amount Variable

double annIntRate; //Annual Interest Rate

double monthIntRate; //Monthly rate for compound amount

double loanMonths; //Loan period in Months for calculation

double monPmt; //Variable to hold monthly payment

float adjmopmt; //variable for rounding monthly payment

double displayRate;

loanYears = 30; //Fixed 30 year loans

annIntRate = .06; //Fixed rate at 6%

displayRate = (annIntRate * 100);

monthIntRate = (annIntRate / 12);

loanMonths = (loanYears * 12);

//Loan Menu

System.out.println("*****************************************************");

System.out.println("SIMPLE HOME LOAN PAYMENT CALCULATOR");

System.out.println("*****************************************************");

System.out.print("How much do is the New Home?\n");

String input = keyin.readln();

//The next 2 lines of code convert the object string to an object Double

//The Object Double can then be converted to a primitive double for calculation

tempAmt = Double.valueOf(input); //Extracts the Object Double to tempAmt var

amtPrin = tempAmt.doubleValue(); //converts double from object Double

//Display results

System.out.println("*****************************************************");

System.out.println("Initial Price:\t $" + amtPrin);

System.out.println("Annual Rate:\t" + displayRate + " Percent");

System.out.println("Years:\t" + loanYears);

System.out.println("Monthly Interest Rate:\t:" + monthIntRate);

System.out.println("Loan in Months:\t" + loanMonths);

//Monthly Payment formula - I am not to sure how accurate the math is, it's close

monPmt = (double) (amtPrin * monthIntRate) / (1 - Math.pow (1 + monthIntRate,-1 * loanMonths));

//Uses a rounding method in Math to limit the zeros in the display

adjmopmt = (float) Math.round(monPmt);

System.out.println("*****************************************************");

System.out.println("Amount Borrowed:\t $" + amtPrin);

System.out.println("Estimated Monthly Payment:\t $" + adjmopmt);

}

'}' <--'}' expected

[3976 byte] By [sdf-1a] at [2007-10-3 4:09:42]
# 1
when you post code, use the code formatter tags, nobody is going to read the code otherwise, at least not me...
SoulTech2012a at 2007-7-14 22:09:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

keyin.java is the name of your file. The name of your class is just keyin.

When the compiler sees "class keyin." it doesn't expect to see a '.' because it expects to be parsing a class name, and the next token after a class name is required to be {

I suggest consulting an introductory tutorial or text on the Java Programming Language.

Also this forum is not for these kinds of questions.

davidholmesa at 2007-7-14 22:09:48 > top of Java-index,Java HotSpot Virtual Machine,Specifications...