For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2006 > Re: why am I getting this error "varible temp1 might not have been initialized&q









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: why am I getting this error "varible temp1 might not have been initialized&q
sandie

2006-03-25, 10:02 pm


I did the following and the program compiled but when exectute, it sits
and wait for input.

float temp2=0;
Scanner keyboard2 = new Scanner(System.in);
System.out.println("Enter a float value with 2 decimal position for
a temperature.");
if (keyboard2.hasNextFloat())
temp2 = keyboard2.nextFloat();

String strScale2 ="C";
System.out.println("Enter one character for degree scale (C or
F).");
if (keyboard2.hasNext())
strScale2 = keyboard2.next();

char scale2 = (strScale2.toUpperCase()).charAt(0);

When run, the program sits and wait for input.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com