Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. public class SecurityJL
  5. {
  6.  
  7. public static void main(String args[])
  8. {
  9. Scanner console = new Scanner(System.in);
  10.  
  11. String input;
  12.  
  13. System.out.println("Enter the student's name, Social Security number, user ID, and password ");
  14. input = console.nextLine();
  15.  
  16. int i = 0;
  17. boolean socialcheck = false;
  18.  
  19.  
  20. while (socialcheck == false)
  21. {
  22. socialcheck = Character.isDigit(input.charAt(i));
  23.  
  24. i++;
  25. }
  26. ;
  27. String name = input.substring(0, i - 1);
  28.  
  29.  
  30. int userstart = i + 10;
  31.  
  32. i = i + 11;
  33.  
  34. boolean userspacecheck = false;
  35.  
  36. while (userspacecheck == false)
  37. {
  38. userspacecheck = Character.isSpaceChar(input.charAt(i));
  39.  
  40. i++;
  41. }
  42.  
  43. String user = input.substring(userstart, i);
  44.  
  45.  
  46. System.out.print(name + "xxx-xx-xxxx" + user);
  47.  
  48.  
  49. String pass = input.substring(i);
  50.  
  51. int passlength = pass.length();
  52.  
  53. int passcounter = 0;
  54.  
  55. while (passcounter < passlength)
  56. {
  57. System.out.print("x");
  58.  
  59. passcounter++;
  60. }
  61.  
  62. }
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. import java.util.*;
  82. import java.lang.*;
  83.  
  84. public class LoanJL
  85. {
  86.  
  87. public static void main(String args[])
  88. {
  89. Scanner console = new Scanner(System.in);
  90.  
  91. System.out.println("Enter the loan amount ");
  92. double loan = console.nextDouble();
  93.  
  94. System.out.println("Enter the interest rate per year as a percentage (consider any number entered as a percentage) ");
  95. double intrate = console.nextDouble();
  96.  
  97. System.out.println("Enter the monthly payment");
  98. double monthpay = console.nextDouble();
  99.  
  100.  
  101. int monthcount = 0;
  102. boolean doable = true;
  103.  
  104.  
  105. while (loan > 0)
  106. {
  107. loan = loan - (monthpay - (intrate / 12) * .01 * loan);
  108.  
  109. if (monthpay < (intrate / 12) * .01 * loan)
  110. {
  111. System.out.println("The monthly payment is too low and the loan amount cannot be repaid.");
  112. doable = false;
  113. break;
  114. }
  115.  
  116. monthcount++;
  117. }
  118.  
  119. if (doable)
  120. System.out.println(monthcount);
  121.  
  122. }
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. import java.util.*;
  144. import java.io.*;
  145.  
  146. public class NamesJL
  147. {
  148.  
  149. public static void main(String args[])
  150. {
  151. try
  152. {
  153. Scanner inFile = new Scanner(new FileReader("Student_Names.txt"));
  154.  
  155. while (inFile.hasNextLine())
  156. {
  157. String line = inFile.nextLine();
  158. System.out.println(format(line));
  159. }
  160. }
  161.  
  162. catch (FileNotFoundException error)
  163. {
  164. System.out.println("Error, file not found");
  165. }
  166.  
  167. }
  168.  
  169. static String format(String line)
  170. {
  171. int i = line.indexOf(',');
  172.  
  173. String last = line.substring(0 , i);
  174.  
  175. i = i + 2;
  176.  
  177. String first = line.substring(i);
  178.  
  179.  
  180. return first + " " + last;
  181. }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement