reached end of file while parsing and while expected

reached end of file while parsing and while expected

import java.io.*; public class temperature{ public static void main(String []args)throws IOException{ BufferedReader steffi = new BufferedReader (new InputStreamReader (System.in));

    double temp=0.0;
    char input2;
    String input1;
    double degreesC=0.0;
    double degreesF=0.0;
    String res;
    char result;



    System.out.println("Enter temperature:");
    temp=Integer.parseInt(steffi.readLine());


    System.out.println("Select where you want to convert the entered temperature. Press either a 'C' (or 'c') for Celsius or an 'F'(or 'f') for Fahrenheit");
    input1=steffi.readLine();
    input2=input1.charAt(0);


    do
    {
    if(input2=='c'||input2=='C')

    {

        degreesC=5*(temp-32)/9;
        System.out.println("Celcius:"+ degreesC);


    }
    else if(input2=='f'||input2=='F')
    {   
        degreesF=(9*(temp)/5)+32;
        System.out.println("Fahrenheit:"+degreesF);

        System.out.println("Do you want to try again?Y/N");
        res=steffi.readLine();
        result=res.charAt(0);

    }while(result=='Y');
        System.out.println("Thank you for using this application!");



        }       
    }
View Answers

May 18, 2013 at 7:29 PM

hi friend,

You have not closing the curly braces properly. Please check your code and close the curly braces properly.

Try the following code this will not generate error for reached end of file while parsing and while expected

import java.io.*; 
public class temperature
{
    public static void main(String []args)throws IOException
    {
        BufferedReader steffi = new BufferedReader (new InputStreamReader (System.in));
        double temp=0.0;
        char input2;
        String input1;
        double degreesC=0.0;
        double degreesF=0.0;
        String res;
        char result;
//      System.out.println("Enter temperature:");
//      temp=Integer.parseInt(steffi.readLine());
//      System.out.println("Select where you want to convert the entered temperature. Press either a 'C' (or 'c') for Celsius or an 'F'(or 'f') for Fahrenheit");
//      input1=steffi.readLine();
//      input2=input1.charAt(0);
        do
        {
            System.out.println("Enter temperature:");
            String deg = steffi.readLine();         
            temp=Double.parseDouble(deg);
            System.out.println("Select where you want to convert the entered temperature. Press either a 'C' (or 'c') for Celsius or an 'F'(or 'f') for Fahrenheit");
            input1=steffi.readLine();
            input2=input1.charAt(0);
            if(input2=='c'||input2=='C')
            {
                degreesC=5*(temp-32)/9;
                System.out.println("Celcius:"+ degreesC);
            }
            else if(input2=='f'||input2=='F')
            {
                degreesF=(9*(temp)/5)+32;
                System.out.println("Fahrenheit:"+degreesF);
                System.out.println("Do you want to try again?Y/N");
            }
            System.out.print("Do you want to continue adding Buyers? [Y/N] ");
            result = (char)steffi.read();           
        }       
        while(result=='Y' || result == 'y');
            System.out.println("Thank you for using this application!");        
        }
}

Thanks.









Related Tutorials/Questions & Answers:
reached end of file while parsing and while expected
reached end of file while parsing and while expected  import java.io.*; public class temperature{ public static void main(String []args)throws...); }while(result=='Y'); System.out.println("Thank you for using
Java error reached end of file while parsing
Java error reached end of file while parsing... an error i.e java error reached end of file while parsing as the class closing braces... of file while parsing ,In this code we want to display Time in hour, minute
Advertisements
-[UIPopoverController dealloc] reached while popover is still visible.
-[UIPopoverController dealloc] reached while popover is still visible.  Hi, I am getting following error in my application: -[UIPopoverController dealloc] reached while popover is still visible. How to solver this? Thanks
Handling Errors While Parsing an XML File
Handling Errors While Parsing an XML File       This Example shows you how to Handle Errors While parsing an XML document. JAXP (Java API for XML Processing) is an interface
Truncating issue while parsing XML with SAX Parser.
Truncating issue while parsing XML with SAX Parser.  I am Parsing one xml file and after parsing I have to enter the data into the database using hibernate. The problem is while parsing some elements, its not getting the complete
problem while reading .csv file
problem while reading .csv file  I have a problem here..... i am reading a .csv extention file which has some value....but the problem is der is an amount column which contains , in between (eg) 3,899.00 which inturns creates
while and do while
while and do while  hello, What is the difference between a while statement and a do statement?   hello,ADS_TO_REPLACE_1 A while... should occur. A do statement checks at the end of a loop to see whether the next
Ignoring Comments While Parsing an XML File
Ignoring Comments While Parsing an XML File   ... in an XML File. JAXP is an interface which provides parsing of xml documents. Here... a DocumentBuilder object with the help of a DocumentBuilderFactoryFile file = new File
struts code for scan the file while uploading - Struts
struts code for scan the file while uploading  Hi, I want the file to be scanned with anti-virus while uploading into server. can provide me help in this regard. Thanks in Advance.   For this you need third
Error with Maven while deploying the war file
Error with Maven while deploying the war file  Hi, I am new to maven... I created java spring hibernate project.. and i kept all .java files... war : war. for creating the war. then i deployed the war file in localhost 8080
Error with Maven while deploying the war file
Error with Maven while deploying the war file  Hi, I am new to maven... I created java spring hibernate project.. and i kept all .java files... this command mvn war : war. for creating the war. then i deployed the war file
While and do-while
While and do-while       Nested classes Here is another advantage of the Java, object-oriented programming language that allows us to define a class within another
Err while reading CSV file using POI - Java Beginners
Err while reading CSV file using POI  Hi, When i am trying to read a CSV file using POI Dile system, the below error is coming up. java.io.IOException: Invalid header signature; read 2334956330951926093, expected
The while and do
While and do-while       Lets try to find out what a while statement does. In a simpler language, the while statement continually executes a block of statements while
Pass hidden veritable while uploading file - JSP-Servlet
fields while uploading file on server?" Thanks in advance...Pass hidden veritable while uploading file  Hi All, Is there any way to pass hidden variables in request, from where we are trying to upload file
Handle Null Pointer Exception while text file upload
Handle Null Pointer Exception while text file upload  I want the code... for null pointer exception. The cause for null pointer exception is while uploading text file into database if a different text file is selectedi.e...,my db
Erron while
Erron while   Hi, i'm doing a project regarding xml. I want to extract all nodes from body of existing xml doc to make another xml with that data.Here is my coding and error showing on that coding.Could anybody help to know my
while & do..while Loop
while & do..while Loop while loop The while loop iterate until provided condition is true. Given below the syntax : while (condition)  ...; <?php $j=1; while($j<=3) { echo "Value of j" . $j . "<
convert excel file data into different locales while converting exclile file to csv file
convert excel file data into different locales while converting exclile file to csv file   can any one provide the code for how to convert excel file data into different locales while converting exclile file to csv file
Problem while using a HashMap for writing text ina RTF file. - Framework
Problem while using a HashMap for writing text ina RTF file.  Hi, I am trying to generate a RTF file using iText.jar, wherein I am taking... matched to the string then only write to the RTF file. Problem is Document writes
While and do-while
While and do-while       Lets try to find out what a while statement does. In a simpler language, the while statement continually executes a block of statements while a particular
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: .  i had an error:"XML Parsing Error: mismatched tag. Expected: ." when uploading and writing them into an xml file. i use the jspBean to call the writeXML class. pls help me to solve
php do while syntax
php do while syntax  How to create a do while loop in php. What is the syntax
php do while example
php do while example  Simple example of do while loop in PHP
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
php while loop
php while loop  Example to fetch the data using while loop in PHP
While loop Statement.
While loop Statement.   How to Print Table In java using While Loop
The While keyword
The While keyword       While is a keyword defined in the java programming language. Keywords... programming language likewise the while keyword indicates the following
php array loop while
php array loop while  Using the php array while loop
php do while false
php do while false   Is there any difference between FALSE and false
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
while executing a java program
while executing a java program  while iam executing a simple java program after i type "java simple.java" there was a an error occuring.the error is "exception in thread "main" java.lang.noclassdeffounderror:simple" what thus
do-while loop
do-while loop  how many times will the following loop get executed and what will be the final value of the variable I after execution the loop is over. int I = 5; do{ I + = 3; System.out.println(""+I); I=I+1; }while(I>=9
while loop to for loops
while loop to for loops  I have to change this while loops... to know how to change it. int currentNum= num1; while(num1>num2... Are: "); while(num1 <= num2) { if(num1%2 != 0) { System.out.print
Memory leak in While loop
Memory leak in While loop  How to manage a memory leak in While loop ?   make sure loop is not running infinitley. ------------------------------------ Chandraprakash Sarathe http://javaved.blogspot.com/   
How to include Two multi rows, one with a file Upload and another with normal fields, have problem while including both
How to include Two multi rows, one with a file Upload and another with normal fields, have problem while including both  How to include Two multi rows, one with a file Upload and another with normal fields, have problem while
While loop Statement
While loop Statement  How to print a table using while loop?   The given example displays the multiplication table of the given number... +" = "); while(y<=10) { int t = x
programes on while loop
programes on while loop   write a program to calculate sum of an entered digit write a program to find gcd and lcm of 2 positive integers   Java sum of digits Java Find LCM and GCD
While loop - Java Beginners
While loop  Given a number, write a program using while loop to reverse the digits of the number. Eg. the no. is 12345, should be written as 54321...(br.readLine()); int n=num; int rem=0; int rev=0; while(n!=0
While running jsp
While running jsp  I found this error when i run the client.jsp can anyone help me javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://localhost:8080/WebService1/MyWebService?wsdl. It failed with: http
while loop handling
while loop handling  Dear deepak, thanks for your response yesterday.. I am doing a project on travelling domain.. in that initially i searched all... option the while loop always taking tyhe last flight datails only... and in all
While Loop with JOptionPane
While Loop with JOptionPane  Hello there, why the output only... int k = 5; String name; int age; while(i < k...[]=new String[5]; int arr[]=new int[5]; while(i < k){ String name
Character count by while loop
Character count by while loop  Write the program to count the number of characters entered until a full stop (.)is keyed-in. Anyone there pls help with this question...   import java.io.*; import java.util.*; class
While Loop
While Loop       Loop.... Loop makes your program readable, flexible and reliable. While loop: While loop... the statements or processes written under the while loop are executed otherwise ignored
java code using while loop
java code using while loop  
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
programes on do... while
to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10
Class.forName will do while loading drivers
Class.forName will do while loading drivers  What Class.forName will do while loading drivers
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf using itext?  I am writing a pdf using itext where i add a image in the beginning of the document. When i use image = Image.getInstance("C
while Java Keyword
while Java Keyword       The while is a keyword defined in the java programming language... to a compiler in java programming language likewise the while keyword indicates

Ads