Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. package ktharjutamine;
  2.  
  3. import java.io.File;
  4. import java.io.FileWriter;
  5. import java.io.IOException;
  6. import java.io.Writer;
  7.  
  8. import pena.TextIO;
  9.  
  10. public class Xph {
  11.  
  12.     public static void main(String[] args) {
  13.         System.out.println("Mis skill?");
  14.         String skill = TextIO.getlnString();
  15.         System.out.println("algne xp?");
  16.         int algxp = TextIO.getlnInt();
  17.         System.out.println("lõpp xp?");
  18.         int l6ppxp = TextIO.getlnInt();
  19.         System.out.println("Mitu min jamasid?");
  20.         double aeg = TextIO.getlnDouble();
  21.         System.out.println("xp per hour on" + " " + xpH(aeg, algxp, l6ppxp));
  22.         File file = new File("xptunnis.txt");
  23.         try {
  24.             Writer wr = new FileWriter(file, true);
  25.             wr.write(skill);
  26.             wr.write("\r\n");
  27.             wr.write(Integer.toString(xpH(aeg, algxp, l6ppxp)));
  28.             wr.write("\r\n");
  29.             wr.write("\r\n");
  30.             wr.close();
  31.         } catch (IOException e) {
  32.             System.out.println("S/V viga: " + e);
  33.         }
  34.     }
  35.  
  36.     public static int xpH(double min, int algxp, int uusxp) {
  37.         double tegur = 60 / min;
  38.         int xptunnis = (int) ((uusxp - algxp) * tegur);
  39.         return xptunnis;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement