Advertisement
inferno719

Untitled

Sep 30th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.74 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package lab5;
  6. import java.io.*;
  7. //import java.util.Scanner;
  8. import java.util.*;
  9.  
  10. //import java.*;
  11. /**
  12.  *
  13.  * @author rherman
  14.  */
  15. public class Lab5
  16. {
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) throws IOException
  21.     {
  22.         /*
  23.         System.out.println("Main starts");        
  24.         System.out.println("Reading start.");
  25.         File file = new File("input.txt");
  26.         Scanner in = new Scanner(file);
  27.         //BufferedReader in2 = new BufferedReader(new FileReader("C:\\input.txt"));
  28.         String text = in.nextLine();
  29.         System.out.println(text);
  30.         double x = Double.parseDouble(text);
  31.         System.out.println(x);
  32.         //String y = text
  33.         //in.close();
  34.         //System.out.println(in);
  35.         */
  36.         System.out.println("Main starts");
  37.         System.out.println("Reading start.");
  38.         File file = new File("input.txt");
  39.         Scanner in = new Scanner(file);
  40.         //PrintWriter out = new PrintWriter(new FileWriter("output.txt")));
  41.         while(in.hasNextLine())
  42.         {
  43.             String text = in.nextLine();
  44.             //double value = convert(text);
  45.             double value;
  46.             //Determine the numerical temperature
  47.             StringBuilder clean = new StringBuilder(text);
  48.             char type = clean.charAt(clean.length()-1);
  49.             clean = clean.deleteCharAt(clean.length()-1);
  50.             System.out.println(clean);
  51.            
  52.             //Determine the measurement used.
  53.             clean = new StringBuilder(text);
  54.             clean = clean.deleteCharAt(clean.length()-2);
  55.             clean = clean.deleteCharAt(clean.length()-2);
  56.             try
  57.             {
  58.                 clean = clean.deleteCharAt(clean.length()-2);
  59.                 clean = clean.deleteCharAt(clean.length()-2);
  60.             }
  61.             catch(StringIndexOutOfBoundsException exceptionA)
  62.             {
  63.                 //Empty.  the two deleteCharAts are try-catched in case the input file is shorter than expected.
  64.             }
  65.             System.out.println(clean);
  66.             String a = clean.toString();
  67.             System.out.println(a);
  68.             //String a = clean.ToString();
  69.             //If C is found a the end of the file, run this:
  70.             if (a == "C")
  71.             {
  72.                 System.out.println("C!");
  73.             }
  74.             else if(a == "F")
  75.             {
  76.                 System.out.println("F!");
  77.             }
  78.             else
  79.             {
  80.                 System.out.println("Problem.");
  81.             }
  82.         }
  83.         //out.close();
  84.        
  85.     }    
  86. }      
  87.  
  88.  
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement