Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need Help getting this done! IN JAVA* Create a program that converts a string to

ID: 3606603 • Letter: N

Question

Need Help getting this done! IN JAVA*

Create a program that converts a string to an encrypted string by changing the values of the vowels to numbers entered by the user. For this task, use two arrays of size 5, one to store the vowels, called Vowels, and one to store the numbers, called Numbers. For example, if the user inputs the number 7 for a, 3 for e, 5 for i, 2 for o and 0 for u. The following two arrays should be created: 1. Vowels Numbers 0 2. Create the method readNumbers that will ask a user for the number corresponding to each vowel and store it in the Numbers array. 3. Create a method encryptString that will receive a String and will change the vowels of the String to the corresponding number. For example, using the example numbers provided in 1, if this method receives "This is easy peasy lemon squeezy" it will return "Th5s 5s 37sy p37sy 13m2n squ33sy 4. Create the main method of your program that will: a. Read the numbers for encryption. b. Ask the user: Do you want to encrypt a string? (Y/N) If the answer is "Y", the system should request as an input the string and print the encrypted string. Repeat this until the user indicates he/she doesn't want to encrypt a string, i.e., answer is "N". Trace your program with the following answers from user: 5. a. Ask the user: Do you want to encrypt a string? (Y/N)

Explanation / Answer

import java.util.Scanner;
public class Vowel_encry
{
   //read values for vowels
   public static void readNumbers(char[] Vowels,int[] Numbers)
   {
       Scanner ip=new Scanner(System.in);
      
       for(int i=0;i<5;i++)
       {
           System.out.println("Enter number for "+Vowels[i]);
           Numbers[i]=ip.nextInt();
       }
   }
   //encrypt the message
   public static void encryptString(char[] arr,char[] Vowels,int[] Numbers)
   {
       int length=arr.length;
       for(int i=0;i<length;i++)
       {
           for(int j=0;j<5;j++)
           {
               if(arr[i]==Vowels[j])
               {
                   char temp = (char)(Numbers[j]);
                   arr[i]=temp;
               }
           }
       }
       for(int i=0;i<length;i++)
           System.out.print(arr[i]);
   }
   //main method
   public static void main(String args[])
   {
       Scanner ip=new Scanner(System.in);
       int[] Numbers=new int[5];//numbers to store for vowels
       char[] Vowels = {'a','e','i','o','u'};//vowels
       //read Numbers for vowels
       readNumbers(Vowels,Numbers);
       //prompt and get the choice of user
       System.out.println("Do you want to encrypt a string?[Y/N]");
       char choice = ip.next().charAt(0);
       //till user say no
       while(choice=='Y')
       {
          
           //prompt for message
           System.out.println("Enter msg:");
           //string of msg
           String temp=ip.nextLine();
           //converting string to char array
           char[] arr=temp.toCharArray();
           //encrypt the msg
           encryptString(arr,Vowels,Numbers);
           //prompt again to encrypt another string
           System.out.println("Do you want to encrypt a string?[Y/N]");
           choice = ip.next().charAt(0);
       }
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote