| | |
Simple Question
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 9
Reputation:
Solved Threads: 0
hi im new to java and just need a little help in the right direction. I am trying to display an input of int on number at a time. So for example the user would enter 1998 and the output would be:
1
9
9
8
and we have to use the operators / and %. I know that % is to show the remainder but it just doesn't make sense to me how they could output that on each line. I have tried solving this using just / and - but it doesn't work. Also the input can only be a 4 digit Int
1
9
9
8
and we have to use the operators / and %. I know that % is to show the remainder but it just doesn't make sense to me how they could output that on each line. I have tried solving this using just / and - but it doesn't work. Also the input can only be a 4 digit Int
•
•
Join Date: Jan 2008
Posts: 3,828
Reputation:
Solved Threads: 501
•
•
•
•
hi im new to java and just need a little help in the right direction. I am trying to display an input of int on number at a time. So for example the user would enter 1998 and the output would be:
1
9
9
8
and we have to use the operators / and %. I know that % is to show the remainder but it just doesn't make sense to me how they could output that on each line. I have tried solving this using just / and - but it doesn't work. Also the input can only be a 4 digit Int
year that stores 1998. Have four more variables: thousands , hundreds , tens , ones . If year = 1998, use the / and % operators to put the proper value into each variable so that thousands = 1, hundreds = 9, tens = 9, ones = 8, then display them with 4 separate println commands. Last edited by VernonDozier; Sep 23rd, 2008 at 7:31 pm.
•
•
Join Date: Nov 2007
Posts: 9
Reputation:
Solved Threads: 0
thanks so much
, I'm new to this. You solved one of my problems, so I'm gonna ask another one that you can maybe answer. I was wondering if there was a way to take the first word in a sentence and replace it with last one and vice versa. For example the sentence "My friend is out" would turn into "Out friend is My". I've tried looking for a solution through google and found the .replace() operator, but this requires you to know what you are going to be replacing the word with. What if i don't know what the user will type in and just want the last and first words switched. Also i wouldn't know the index of the last word
, I'm new to this. You solved one of my problems, so I'm gonna ask another one that you can maybe answer. I was wondering if there was a way to take the first word in a sentence and replace it with last one and vice versa. For example the sentence "My friend is out" would turn into "Out friend is My". I've tried looking for a solution through google and found the .replace() operator, but this requires you to know what you are going to be replacing the word with. What if i don't know what the user will type in and just want the last and first words switched. Also i wouldn't know the index of the last word •
•
Join Date: Jan 2008
Posts: 3,828
Reputation:
Solved Threads: 501
•
•
•
•
thanks so much, I'm new to this. You solved one of my problems, so I'm gonna ask another one that you can maybe answer. I was wondering if there was a way to take the first word in a sentence and replace it with last one and vice versa. For example the sentence "My friend is out" would turn into "Out friend is My". I've tried looking for a solution through google and found the .replace() operator, but this requires you to know what you are going to be replacing the word with. What if i don't know what the user will type in and just want the last and first words switched. Also i wouldn't know the index of the last word
Vector of type String called words , each element of words containing a single word. Once you have your words Vector, display the words in any order you wish. So your main task is to break the larger String containing the sentence into smaller Strings, each containing a word. There are several ways to do that. You need to know where a word begins and ends and what defines a word and what separates a word. The Character class can help you with that with functions like isLetter . The String class' substring function can come in handy once you know where a word starts and stops.http://java.sun.com/javase/6/docs/ap...ng/String.html
http://java.sun.com/javase/6/docs/ap...Character.html
![]() |
Similar Threads
- simple question (C++)
- Quick Question: Is J# the same thing as Java? (Java)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Ribbon Question (Motherboards, CPUs and RAM)
- Simple question (Windows Servers and IIS)
- Simple Question (Linux Servers and Apache)
- A simple question about CMOS batteries (Motherboards, CPUs and RAM)
- XP Pro (re)activation question (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Swing and threads
- Next Thread: Runtime classname of null object
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth busy_handler(null) chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia link linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads time tree unlimited utility webservices windows






