SHARE
TWEET

Untitled

advictoriam Mar 14th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.     Solution Checker Broken
  3. */
  4.  
  5. import java.io.FileReader;
  6. import java.io.FileNotFoundException;
  7. import java.util.Scanner;
  8. import java.io.PrintWriter;
  9.  
  10. public class CityTemps
  11. {
  12.    public static void main(String[] args)
  13.       throws FileNotFoundException
  14.    {
  15.       String inputFileName = "celsius.txt";
  16.       String outputFileName = "fahrenheit.txt";
  17.  
  18.       FileReader fr = new FileReader(inputFileName);
  19.       PrintWriter writer = new PrintWriter(outputFileName);
  20.      
  21.       try
  22.       {
  23.          String c = "";
  24.          while(true)
  25.          {
  26.             int ch = fr.read();
  27.          
  28.             if(ch == -1)
  29.                break;
  30.             else if((char)ch == '\n')
  31.             {
  32.                writer.write(String.format("%f\n", (float)((Float.parseFloat(c)*(9/5))+32)));
  33.                c = "";
  34.             }
  35.             else if(Character.isDigit((char)ch) || (char)ch == '.')
  36.                c += (char)ch;
  37.             writer.write((char)ch);
  38.          }
  39.       }
  40.       catch(Exception e){}
  41.      
  42.       try
  43.       {
  44.          fr.close();
  45.          writer.close();
  46.       }
  47.       catch(Exception e){}
  48.    }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top