1

I have successfully written a program to convert 1 character at a time, However I must now ask the user to choose the number of characters they wish to convert and use a sentinel-controlled loop for data validation and a counter-controlled loop for processing control in my program.

import java.util.Scanner;

public class jtwalsh_LeetLoop {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int total;
        int counter;
        counter = 1;

        System.out.print( "How many characters would you like to test? ");
        int total = input.nextInt();

        while ( counter <= total)
            System.out.print( "Enter a character to test: " );
        char ch;
        ch = input.next() .charAt(0);}

    counter = counter"";

    switch ( ch ) {
        case 'a': case 'A':
            System.out.printf( "%c @\n", ch );
            break;
        case 'b': case 'B':
            System.out.printf( "%c I3\n", ch );
            break;
        case 'c': case 'C':
            System.out.printf( "%c <\n", ch );
            break;
        case 'd': case 'D':
            System.out.printf( "%c [)\n", ch );
            break;
        case 'e': case 'E':
            System.out.printf( "%c &\n", ch );
            break;
        case 'f': case 'F':
            System.out.printf( "%c ]=\n", ch );
            break;
        case 'g': case 'G':
            System.out.printf( "%c 6\n", ch );
            break;
statox
  • 2,827
  • 1
  • 21
  • 41
J. Doe
  • 11
  • 2

0 Answers0