Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- public class SecurityJL
- {
- public static void main(String args[])
- {
- Scanner console = new Scanner(System.in);
- String input;
- System.out.println("Enter the student's name, Social Security number, user ID, and password ");
- input = console.nextLine();
- int i = 0;
- boolean socialcheck = false;
- while (socialcheck == false)
- {
- socialcheck = Character.isDigit(input.charAt(i));
- i++;
- }
- ;
- String name = input.substring(0, i - 1);
- int userstart = i + 10;
- i = i + 11;
- boolean userspacecheck = false;
- while (userspacecheck == false)
- {
- userspacecheck = Character.isSpaceChar(input.charAt(i));
- i++;
- }
- String user = input.substring(userstart, i);
- System.out.print(name + "xxx-xx-xxxx" + user);
- String pass = input.substring(i);
- int passlength = pass.length();
- int passcounter = 0;
- while (passcounter < passlength)
- {
- System.out.print("x");
- passcounter++;
- }
- }
- }
- import java.util.*;
- import java.lang.*;
- public class LoanJL
- {
- public static void main(String args[])
- {
- Scanner console = new Scanner(System.in);
- System.out.println("Enter the loan amount ");
- double loan = console.nextDouble();
- System.out.println("Enter the interest rate per year as a percentage (consider any number entered as a percentage) ");
- double intrate = console.nextDouble();
- System.out.println("Enter the monthly payment");
- double monthpay = console.nextDouble();
- int monthcount = 0;
- boolean doable = true;
- while (loan > 0)
- {
- loan = loan - (monthpay - (intrate / 12) * .01 * loan);
- if (monthpay < (intrate / 12) * .01 * loan)
- {
- System.out.println("The monthly payment is too low and the loan amount cannot be repaid.");
- doable = false;
- break;
- }
- monthcount++;
- }
- if (doable)
- System.out.println(monthcount);
- }
- }
- import java.util.*;
- import java.io.*;
- public class NamesJL
- {
- public static void main(String args[])
- {
- try
- {
- Scanner inFile = new Scanner(new FileReader("Student_Names.txt"));
- while (inFile.hasNextLine())
- {
- String line = inFile.nextLine();
- System.out.println(format(line));
- }
- }
- catch (FileNotFoundException error)
- {
- System.out.println("Error, file not found");
- }
- }
- static String format(String line)
- {
- int i = line.indexOf(',');
- String last = line.substring(0 , i);
- i = i + 2;
- String first = line.substring(i);
- return first + " " + last;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement