[TxMt] Exception in thread "main" java.lang.NumberFormatException: null

Alex Podaras apod at cursed.gr
Fri Jan 18 16:14:44 UTC 2008


Hello Andre,

and welcome :)
The problem is that your program takes some input from the user  
through command line.

You can solve this by opening your Bundle Editor <Control+Alt+Command  
B> and navigate
to the Java>Compile & Run Single File Command, then duplicate the  
command by pressing
the double plus icon at the bottom left, name your new command  
something like "Compile & Run Single File in Terminal"

And insert this:

------
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Compiling “${TM_FILENAME}”…"

cd "$TM_DIRECTORY"
javac -encoding UTF8 "$TM_FILENAME" &> >("${TM_RUBY:-ruby}" - 
rtm_parser -eTextMate.parse_errors)
if (($? >= 1)); then exit; fi

# { java -Dfile.encoding=utf-8 "${TM_FILENAME%.java}"
#   echo -e "\nProgram exited with status $?."; }|pre

# # if you want to run the program in Terminal.app
osascript <<EOF
    tell application "Terminal"
       activate
       do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
    end tell
EOF

html_footer
------

This is the same command as "Compile & Run Single File" with some  
commented and uncommented lines for
running your program in terminal after the compilation.

Hope this helps.

Regards,
Alex

On Jan 18, 2008, at 5:42 PM, Andre Hugo wrote:

> import java.io.*;
>
> public class Bert
> {
>  	public static void main(String[] args) throws IOException
>  	{
> 	   	//Declaring Variables
> 	   	int price, downpayment, tradeIn, months, loanAmt;
> 	   	double annualInterest, payment, interest;
> 	   	String custName, inputPrice, inputDownPayment, inputTradeIn,  
> inputMonths, inputAnnualInterest;
> 	   	BufferedReader dataIn = new BufferedReader(new  
> InputStreamReader(System.in));
>
> 	   //Get Input from User
> 		System.out.println("What is your name?  ");
> 		  custName = dataIn.readLine();
> 		System.out.print("What is the price of the car?  ");
> 		  inputPrice = dataIn.readLine();
> 		System.out.print("What is the downpayment?  ");
> 		  inputDownPayment = dataIn.readLine();
> 		System.out.print("What is the trade-in value?  ");
> 			inputTradeIn = dataIn.readLine();
> 		System.out.print("For how many months is the loan?  ");
> 		  inputMonths = dataIn.readLine();
> 		System.out.print("What is the decimal interest rate?  ");
> 		  inputAnnualInterest = dataIn.readLine();
>
> 		//Conversions
> 		price = Integer.parseInt(inputPrice);
> 		downpayment = Integer.parseInt(inputDownPayment);
> 		tradeIn = Integer.parseInt(inputTradeIn);
> 		months = Integer.parseInt(inputMonths);
> 		annualInterest = Double.parseDouble(inputAnnualInterest);
>
> 		//Calculations
> 		interest = annualInterest / 12;
> 		loanAmt = price - downpayment - tradeIn;
> 		payment = loanAmt / ((1 / interest) - ( 1 / (interest * Math.pow(1  
> + interest, months))));
>
> 		//Output
> 		System.out.print("The monthly payment for " + custName + " is $");
> 		System.out.println(payment);
>  	}
> }




More information about the textmate mailing list