Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Solution Checker Broken
- */
- import java.io.FileReader;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- import java.io.PrintWriter;
- public class CityTemps
- {
- public static void main(String[] args)
- throws FileNotFoundException
- {
- String inputFileName = "celsius.txt";
- String outputFileName = "fahrenheit.txt";
- FileReader fr = new FileReader(inputFileName);
- PrintWriter writer = new PrintWriter(outputFileName);
- try
- {
- String c = "";
- while(true)
- {
- int ch = fr.read();
- if(ch == -1)
- break;
- else if((char)ch == '\n')
- {
- writer.write(String.format("%f\n", (float)((Float.parseFloat(c)*(9/5))+32)));
- c = "";
- }
- else if(Character.isDigit((char)ch) || (char)ch == '.')
- c += (char)ch;
- writer.write((char)ch);
- }
- }
- catch(Exception e){}
- try
- {
- fr.close();
- writer.close();
- }
- catch(Exception e){}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement