Share on Google+Share on Google+

Steffi Grace M. Dimalibot
reached end of file while parsing and while expected
1 Answer(s)      3 years and 10 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!");



        }       
    }

Ads

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
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
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
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
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads