Need Help with Java Program: Uppercase & Lowercase Conversion

  • Context: Comp Sci 
  • Thread starter Thread starter sankalpmittal
  • Start date Start date
  • Tags Tags
    Java Program
Click For Summary

Discussion Overview

The discussion revolves around a Java programming homework assignment that requires participants to create a program for converting lowercase letters to uppercase and vice versa, while handling special characters by leaving a blank space. The output must be displayed in a specific format, directly in front of the input character.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes the homework requirements and their attempt at a solution, noting difficulty in formatting the output correctly.
  • Another participant suggests using two variables to store the original and converted characters, but acknowledges the requirement to display only the converted character next to the input.
  • A later reply mentions the challenge of moving the cursor in standard console I/O and suggests alternatives like creating a GUI or using ANSI escape sequences to manipulate cursor position.
  • There is a suggestion to follow a simpler approach by repeating the input after processing, rather than trying to manipulate cursor position.

Areas of Agreement / Disagreement

Participants express differing views on how to achieve the desired output format, with some focusing on technical limitations of console I/O and others proposing alternative methods. No consensus is reached on the best approach to solve the problem.

Contextual Notes

Limitations include the constraints of standard console I/O for cursor manipulation and the potential complexity of using GUI frameworks or ANSI escape codes.

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