I'm new to Java and programming in general. This is baffling me, and I feel like I may just need to scrap what I have and go a different route, but I don't know what route to take.

Below is the code I've written for translating a line from the user into braille. It works! Unfortunately, it works vertically. How can I, after using three lines to create the braille, make the next braille character appear next to the previous one instead of below it?

import java.util.*;

public class Program4
{

    public static String code1 = ". |";
    public static String code2 = " .|";
    public static String code3 = "..|";
    public static String code4 = "  |";

    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);

        System.out.println("Program 4 by Ross Walker");
        System.out.println();

        String s;
        System.out.println("Please give a line to translate");
        s = keyboard.nextLine();

        for(int i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if(c == '1' || c == 'a')
            {
                //new Program4().letterA(s.charAt(i));
                System.out.printf("%s%n%s%n%s%n", code1, code4, code4);
                System.out.println();
            }

            if((c == '2' ) || (c == 'b'))
            {
                System.out.printf("%s%n%s%n%s%n", code1, code1, code4);
                System.out.println();
            }
            if((c == '3') || (c == 'c'))
            {
                System.out.println(code3);
                System.out.println(code4);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '4') || (c == 'd'))
            {
                System.out.println(code3);
                System.out.println(code2);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '5') || (c == 'e'))
            {
                System.out.println(code1);
                System.out.println(code2);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '6') || (c == 'f'))
            {
                System.out.println(code3);
                System.out.println(code1);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '7') || (c == 'g'))
            {
                System.out.println(code3);
                System.out.println(code3);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '8') || (c == 'h'))
            {
                System.out.println(code1);
                System.out.println(code3);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '9') || (c == 'i'))
            {
                System.out.println(code2);
                System.out.println(code1);
                System.out.println(code4);
                System.out.println();
            }
            if((c == '0') || (c == 'j'))
            {
                System.out.println(code2);
                System.out.println(code3);
                System.out.println(code4);
                System.out.println();
            }
        }
    }
}

I've only written up to j in the alphabet. I'll continue if this is the only way I can get it done, but I'd like your help to do it the right way if possible.

0

There are 0 best solutions below