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

I\'m in java 1 and i need help. can you help me write this code. I really will a

ID: 3666944 • Letter: I

Question

I'm in java 1 and i need help. can you help me write this code. I really will appreciate your help.thank you.

For this program, ask the user how many characters they will convert and then use a counter-controlled loop to prompt and convert that many characters. Your program should only convert as many characters as the user has said she will convert. If the value is out of range, you must display an error message as shown in the Sample Program Runs shown on page 2 of this assignment

When prompting the user for how many characters she will convert, validate that they enter a number greater than 0 before allowing them to actually convert characters. This validation should be driven by a sentinel-controlled loop.

All of the previous guidelines and restrictions about how to display the 1337 characters apply from program #6. Refer to program #6's assignment sheet to get the full description of output requirements. You must convert characters from A to Z and a to z correctly and generate appropriate output for characters that can't be converted.

Goals

? Use a sentinel-controlled loop for data validation and a counter-controlled loop for processing control in your program.

? Embed a switch statement inside of a looping structure.

? Modify existing code to extend the functionality of a program.

When converting your input to 1337 code, this program must follow the output requirements already set forth in program #6 earlier this semester.

Make sure to have appropriate spacing, etc.

? You must use a switch statement and not a series of nested if/else statements to implement this program. Failure to use a switch statement

to implement the solution will result in your program not being graded.

1337 Code Alphabet REMINDER FROM PROGRAM 6: There are many different mappings for each letter to be found online. These are the ones this program will use Character A, a B, b C, C D, d E, e F, f G, 9 H, h I, i 1337 Code Comment Vert bars:| Parentheses Vert. Bar: I Number 0 Capital I Dollar sign N, n O, o P, P I3 Capital I R, r I2 Sar brkt: T, t 6 Underscore: Number 1 Underscore Lowercase v's and Lowercase j Y, y K, k M, m Character 2 1337 Code Comment

Explanation / Answer

/**The java program that prompts user to enter how many characters to read.
* Then prompts the character to enter the display the corresponding 1337 code
* */
//Conversion.java
import java.util.Scanner;
public class Conversion
{
   public static void main(String[] args) {
  
      
       int n;
       //Create an instance of Scanner class
       Scanner scanner=new Scanner(System.in);
      
       //read until a valid number is entered.
       do
       {
           System.out.print("How many characters would you like to convert?");
           //read integer value n from user
           n=Integer.parseInt(scanner.nextLine());
          
           //Check if n is valid
           if(n<0)
               System.out.println("Invalid value entered. Try again.");
              
       }while(n<0);
      
       String code="-";
       char ch = ' ';
       //Convert the the character to code
       for(int index=0;index<n;index++)
       {
           //prompt for the character
           System.out.println("Enter character # "+(index+1)+" to convert: ");
           ch=scanner.nextLine().charAt(0);
          
           //Select the corresponding code
           switch(ch)
           {
           case 'A':
           case 'a':
               code="@";
           break;
           case 'B':
           case 'b':
               code="I3";
           break;
           case 'C':
           case 'c':
               code="<";
           break;
           case 'D':
           case 'd':
               code="[)";
           break;
           case 'E':
           case 'e':
               code="&";
           break;
           case 'F':
           case 'f':
               code="]=";
           break;
           case 'G':
           case 'g':
               code="6";
           break;
           case 'H':
           case 'h':
               code="]-[";
           break;
           case 'I':
           case 'i':
               code="1";
           break;
           case 'J':
           case 'j':
               code="_/";
           break;
           case 'K':
           case 'k':
               code="X";
           break;
           case 'L':
           case 'l':
               code="7";
           break;
           case 'M':
           case 'm':
               code="//\//\";
           break;
           case 'N':
           case 'n':
               code="|\|";
           break;
           case 'O':
           case 'o':
               code="()";
           break;
           case 'P':
           case 'p':
               code="|*";
           break;
           case 'Q':
           case 'q':
               code="0,";
           break;
           case 'R':
           case 'r':
               code="I2";
           break;
           case 'S':
           case 's':
               code="$";
           break;
           case 'T':
           case 't':
               code="+";
           break;
           case 'U':
           case 'u':
               code="(_)";
           break;
           case 'W':
           case 'w':
               code="vv";
           break;
           case 'X':
           case 'x':
               code="><";
           break;
           case 'Y':
           case 'y':
               code="j";
           break;
           case 'Z':
           case 'z':
               code="2";
           break;
           }          
          
           //print the ch and code
           System.out.println(ch+" "+code);
           //set code='-'
           code="-";
       }      
   }
}

----------------------------------------------------------------------------------------------------------------------------------------

Sample Output:

How many characters would you like to convert?-1
Invalid value entered. Try again.
How many characters would you like to convert?5
Enter character # 1 to convert:
%
% -
Enter character # 2 to convert:
a
a @
Enter character # 3 to convert:
A
A @
Enter character # 4 to convert:
B
B I3
Enter character # 5 to convert:
b
b I3

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