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.

Ads









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
-[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
Advertisements
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
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... object with the help of a DocumentBuilderFactoryFile file = new File("Document4.xml
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
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
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
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
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
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/   
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 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
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 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
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
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
java code using while loop
java code using while loop  
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
programes on do... while
= num; //use to check at last time int check=0,remainder; while(num > 0
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
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

Ads