Jump to content

Repeating words

AntiHero
Go to solution Solved by minibois,
12 minutes ago, AntiHero said:

probably cause i just started learning this and dont know any better, hence me asking everyone here. 

Sorry if my reply sounded irritated, it was a genuine question (the code struck me as odd, with the question you wrote down).

The kind of format you need to use is something like this:

 

// ask for input and save that
// Print the input as uppercase
// Print it as lower case
// Print the original input

You basically got all the necessary code in your original post, just gotta work with it a little different.

 

(so you ask for input, print input.toUpperCase(), print input.toLowerCase() and print input itself).

 

EDIT: P.S. scan.NextLine = asking for input

Well, here's the question and here's what i have (which is clearly not working). "Write a program that reads a word from the java console. Your program should then output the same word, first output in all uppercase, then output in all lowercase, then output the original word."

 


import java.util.Scanner;

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

    System.out.println( "Enter anyword > ");
    String word1 = scan.nextLine().toUpperCase();
    System.out.println( word1 );
    String word2 = scan.nextLine().toLowerCase();
    System.out.println( word2 );
    String word3 = scan.nextline();
    System.out.println( word3 );

    }
}

I went back over notes and previously written code to dig for an answers, found nothing thus far, will continue in the mean time.

Link to comment
Share on other sites

Link to post
Share on other sites

Why are you using scan.nextLine three times? Just ask for the input once, print it in uppercase, lowercase and normally.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, minibois said:

Why are you using scan.nextLine three times? Just ask for the input once, print it in uppercase, lowercase and normally.

probably cause i just started learning this and dont know any better, hence me asking everyone here. 

Link to comment
Share on other sites

Link to post
Share on other sites

the professor has done a poor job at explaining how tools can be used and im not a fan of this "give you half the knowledge you need and expect you to figure the rest out" style of teaching, maybe if the subject was different... but its forces me to turn to alternative resources like the forums to learn. 

Link to comment
Share on other sites

Link to post
Share on other sites

12 minutes ago, AntiHero said:

probably cause i just started learning this and dont know any better, hence me asking everyone here. 

Sorry if my reply sounded irritated, it was a genuine question (the code struck me as odd, with the question you wrote down).

The kind of format you need to use is something like this:

 

// ask for input and save that
// Print the input as uppercase
// Print it as lower case
// Print the original input

You basically got all the necessary code in your original post, just gotta work with it a little different.

 

(so you ask for input, print input.toUpperCase(), print input.toLowerCase() and print input itself).

 

EDIT: P.S. scan.NextLine = asking for input

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, AntiHero said:

the professor has done a poor job at explaining how tools can be used and im not a fan of this "give you half the knowledge you need and expect you to figure the rest out" style of teaching, maybe if the subject was different... but its forces me to turn to alternative resources like the forums to learn. 

Maybe that's the better way to teach, instead of giving you the whole knowledge, he forced you to find your way in.

There's many solution you can google it. He teaches you how a problem solving work in real life.

Even the best coders will eventually find solution on the web and learn something new in the process.

Ryzen 5700g @ 4.4ghz all cores | Asrock B550M Steel Legend | 3060 | 2x 16gb Micron E 2666 @ 4200mhz cl16 | 500gb WD SN750 | 12 TB HDD | Deepcool Gammax 400 w/ 2 delta 4000rpm push pull | Antec Neo Eco Zen 500w

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, SupaKomputa said:

Maybe that's the better way to teach, instead of giving you the whole knowledge, he forced you to find your way in.

There's many solution you can google it. He teaches you how a problem solving work in real life.

Even the best coders will eventually find solution on the web and learn something new in the process.

maybe so, but it can be frustrating at times when i have a mountain of other classwork to finish and a day job to consider... sometimes just gotta throw in the towel and ask someone.

Link to comment
Share on other sites

Link to post
Share on other sites

https://stackoverflow.com is a better forum to find solution to coding problems.

Ryzen 5700g @ 4.4ghz all cores | Asrock B550M Steel Legend | 3060 | 2x 16gb Micron E 2666 @ 4200mhz cl16 | 500gb WD SN750 | 12 TB HDD | Deepcool Gammax 400 w/ 2 delta 4000rpm push pull | Antec Neo Eco Zen 500w

Link to comment
Share on other sites

Link to post
Share on other sites

20 minutes ago, minibois said:

Sorry if my reply sounded irritated, it was a genuine question (the code struck me as odd, with the question you wrote down).

The kind of format you need to use is something like this:

 


// ask for input and save that
// Print the input as uppercase
// Print it as lower case
// Print the original input

You basically got all the necessary code in your original post, just gotta work with it a little different.

 

(so you ask for input, print input.toUpperCase(), print input.toLowerCase() and print input itself).

 

EDIT: P.S. scan.NextLine = asking for input

Success! thank you!

 


import java.util.Scanner;

public class UpperLowerCase
{
   public static void main( String [ ] args )
   {
    Scanner scan = new Scanner( System.in );
    
    System.out.println("Enter anyword >");
    String word1 = scan.next();   
    System.out.println( word1.toUpperCase() );
    System.out.println( word1.toLowerCase() );
    System.out.println( word1 );
    }
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×