Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners reached end of file while parsing and while expected
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Steffi Grace M. Dimalibot
reached end of file while parsing and while expected
1 Answer(s)      a year and 6 months ago
Posted in : Java Beginners


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!");



        }       
    }

Advertisement
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
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
while and do while
while and do while  hello, What is the difference between a while statement and a do statement?   hello, A while statement checks... statement checks at the end of a loop to see whether the next iteration
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
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
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
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
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
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
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 . "<
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
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
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
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
While loop Statement.
While loop Statement.   How to Print Table In java using While Loop
php while loop
php while loop  Example to fetch the data using while loop in PHP
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
php do while example
php do while example  Simple example of do while loop in PHP
php do while syntax
php do while syntax  How to create a do while loop in php. What is the syntax
php array loop while
php array loop while  Using the php array while loop
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
 

 

 

DMCA.com