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



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

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 3 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
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
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
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
'while' Statement
of the while statement is to repeat a group of Java statements many times... the while keyword. General Form The while statement has this form: while (condition) { statements to repeat while the condition is true
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
php do while false
php do while false   Is there any difference between FALSE and false
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
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/   
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
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
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
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
programes on do... while
= num; //use to check at last time int check=0,remainder; while(num > 0
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
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
 

 

 

DMCA.com