Comp Sci Need Help with Java Program: Uppercase & Lowercase Conversion

  • Thread starter Thread starter sankalpmittal
  • Start date Start date
  • Tags Tags
    Java Program
Click For Summary
The discussion revolves around a Java programming assignment that requires converting user-inputted lowercase letters to uppercase and vice versa, while leaving special characters blank. The main challenge is to display the converted character directly next to the original input without repeating it. Suggestions include using variables to store both the original and converted characters, and utilizing ANSI escape sequences for cursor manipulation, although this may not be reliable across all systems. A simpler alternative is to print the converted character on a new line after the input. The conversation emphasizes the need for clarity in output formatting while adhering to the assignment's requirements.
sankalpmittal
Messages
785
Reaction score
27
My teacher gave me a program in Java which none of us were able to do. So, I need help.

Homework Statement


We have to find the uppercase of the lowercase alphabets which the user inputs and vice versa. In case the character is special character, then it will leave blank space. It will work till the user wishes and the output of the program should be in front of the input. Example :

A a
v V
*
l L


Homework Equations


No equations.


The Attempt at a Solution


I did this program but the only thing I was unable to do was to get the output just in front of the input.
 
Physics news on Phys.org
sankalpmittal said:
My teacher gave me a program in Java which none of us were able to do. So, I need help.

Homework Statement


We have to find the uppercase of the lowercase alphabets which the user inputs and vice versa. In case the character is special character, then it will leave blank space. It will work till the user wishes and the output of the program should be in front of the input. Example :

A a
v V
*
l L


Homework Equations


No equations.


The Attempt at a Solution


I did this program but the only thing I was unable to do was to get the output just in front of the input.

For each character that you process you have one variable with the original character, and another variable with the capped (or uncapped) version of the letter. When you display the results, print the final version of the character, and then the original letter.
 
Mark44 said:
For each character that you process you have one variable with the original character, and another variable with the capped (or uncapped) version of the letter. When you display the results, print the final version of the character, and then the original letter.

That is okay but what our teacher has asked us to do is to print the capped( or uncapped ) version in front of the character inputted by the user. Means we don't have to print the user given character again.

User inputs : I
the output will be i in the same line. That is :

I i

I thought of another way but am unable to find the unicode of the up arrow key.
 
Hi sankalpmittal!

Standard console I/O does not allow for moving the cursor up.
To do so, you will need some kind of extension that requires you to bypass the standard console I/O functions.
It is certainly not an unicode character.

Usually it's best to avoid such extensions, since they do not always work.

Or if you want to make a neat user interface, create a graphics user interface (GUI).
That would not do what you requested though.
In Java you can create a GUI with the JFC/Swing package (google it).

If you really want to, you can use perhaps ANSI escape sequences.
(See: http://en.wikipedia.org/wiki/ANSI_escape_code).
Printing the string "\x1B[1F" should move your cursor to the beginning of the previous line.
But you'll have to try it out to see if it works for you.


I recommend what Mark already suggested: after the input, output a line that repeats the input.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
13K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K