import java.util.Random; import java.util.Scanner; /** * Write a program that asks the user for an int and uses it as a seed for the random number generator. Then the program should ask the user for a password. The program should then randomly generate a salt of five characters and append it to the password * @author Janaye Austin * @since 11/7/19 */ public class SaltPassword { public static void main (String[] args) { newPassword(); } public static void newPassword() { Scanner scan = new Scanner(System.in); String password1; System.out.println("Enter seed:"); int seed = scan.nextInt(); Random rng = new Random(seed); char random1 = (char)(rng.nextInt(58) + 65); char random2 = (char)(rng.nextInt(58) + 65); char random3 = (char)(rng.nextInt(58) + 65); char random4 = (char)(rng.nextInt(58) + 65); char random5 =(char)(rng.nextInt(58) + 65); String finalPassword = "" + random1 + random2 + random3 + random4 + random5; System.out.println("Enter a password:"); scan.nextLine(); password1 = scan.nextLine(); System.out.println("Salt: " + finalPassword); System.out.println("Salted password: " + password1 + finalPassword); } }
Here is another program that I wrote!
import java.util.Scanner; /** * Make a program that counts how many pennies you have inputted into a coin machine, compute the earnings and the processing fee and then print out a receipt. * @author Janaye Austin * @since 10/31/19 */ public class CoinStar { public static void main (String[] args) { depositCoins(); } public static void depositCoins() { Scanner scan = new Scanner(System.in); System.out.println("How many pennies did you insert?"); int pennies = scan.nextInt(); final double percent = .20; int findAmount = pennies; double finalMoney = (double)Math.round(findAmount); System.out.println("You have deposited $" + finalMoney / 100.00); double payUp = finalMoney * percent / 100; System.out.println("The processing fee is: $" + payUp); System.out.println("You earned $" + ((finalMoney / 100.00) - payUp)); } }
I have really liked learning how to code this semester and I am finding that I enjoy it!
Please do click on this rupee to learn some more cool things about me!