Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.BufferedReader;
- import java.util.Scanner;
- public class NewExam
- {
- static String txtw="";
- public static void main (String[] args)
- {
- String input ="";
- //String input = new Scanner(System.in).nextLine();
- String path = "D:\\Study\\Java\\NewMain\\src\\input.txt";
- File file = new File(path);
- try
- {
- BufferedReader br = new BufferedReader (new FileReader(file));
- String line="";
- while ((line = br.readLine()) != null)
- {
- input = line;
- check(input);
- }
- br.close();
- }
- catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- static void check (String inputname)
- {
- char[] lower = "abcdefghijklmnopqrstuvwxyz" .toCharArray();
- char[] higher = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" .toCharArray();
- char[] lowerdecode = "ZYXWVUTSRQPONMLKJIHGFEDCBA" .toCharArray();
- char[] higherdecode = "zyxwvutsrqponmlkjihgfedcba" .toCharArray();
- String sumtext="";
- int inputlong = inputname.length();
- char[] cinput = inputname.toCharArray();
- for (int a=0;a<inputlong;a++)
- {
- if(Character.isLetter(cinput[a]))
- {
- for (int i = 0 ; i < 26 ; i++)
- {
- if(cinput[a] == lower[i])
- {
- String tmp = Character.toString(lowerdecode[i]);
- sumtext += tmp;
- }
- else if (cinput[a] == higher[i])
- {
- String tmp2 = Character.toString(higherdecode[i]);
- sumtext += tmp2;
- }
- }
- }
- else
- {
- String tmp3 = Character.toString(cinput[a]);
- sumtext += tmp3;
- }
- }
- txtw = sumtext+"\n";
- System.out.print(txtw);
- writefile();
- }
- static void writefile ()
- {
- try
- {
- FileWriter writer = new FileWriter("D:\\Study\\Java\\NewMain\\src\\output.txt",true);
- writer.write(txtw);
- writer.write(System.getProperty( "line.separator" ));
- writer.close();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement