Number that is a multiple of 9 and all digits are even?
I've writen this short program to find a number that is a multiple of 9 yet all its digits are even. Here is the code. I'm sure its not very compact and am doing this the hard way.
public class alldigitseven
public static void main(String[] args)
int number = 0;
String numberString, tempString;
char tempChar;
int tempInt, matches = 0, stringLength;
double tempRemainder;
boolean answer = false;
while (answer != true)
// add 9 to the number
if (number < 1000000)
number += 9;
// convert the int to a string
numberString = "" + number;
stringLength = numberString.length();
for (int i = 0; i <= stringLength; i++)
tempChar = numberString.charAt(i);
tempString = "" + tempChar;
tempInt = Integer.parseInt(tempString);
tempRemainder = tempInt%2;
if (tempRemainder == 0)
matches++;
if (matches == stringLength - 1)
System.out.println (numberString);
answer = true;
}anways the code complies fine however when I run it, I get the error
"StringIndexOutOfBoundsException:
String index out of range: 1 (in Java.lang.String)"
What do I need to do to fix this?
here was the final code if anyone was curious...
public class alldigitseven
public static void main(String[] args)
int number = 0;
String numberString, tempString;
char tempChar;
int tempInt, matches = 0, stringLength;
int tempRemainder;
boolean answer = false;
while (answer != true)
// reset matches
matches = 0;
// add 9 to the number
if (number < 1000)
number += 9;
else
answer = true;
// convert the int to a string
numberString = "" + number;
stringLength = numberString.length();
for (int i = 0; i < stringLength; i++)
tempChar = numberString.charAt(i);
tempString = "" + tempChar;
tempInt = Integer.parseInt(tempString);
tempRemainder = tempInt%2;
if (tempRemainder == 0)
matches++;
if (matches == stringLength)
System.out.println (numberString);
answer = true;
}
Similar Messages
-
Number of connection to this computer limited and all connections are in use right now
I have Lenovo ThinkPad T520 (i7, NVIDIA 4200TM) with dock station and two monitors. Sometimes when I close notebook and undock it from dock station. Then I cannot login to my notebook because of error "Number of connection to this computer limited and
all connections are in use right now". This is screenshot of my laptop http://i.imgur.com/6MXnQKf.jpg
Laptop is not in domain and does not have remote desktop connections. It was just turned in sleep mode and late turned on.
This happen pretty often one from 10..20 times of undock. It did not happen with Windows 7 before.The network does not work properly after you resume the computer. This kind of issues are cuased by the network device driver. Download the latess Windows 8 driver from Lenovo website and install it.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ” -
In "find my iphone" i got message that its offline Although its online and all settings are OK
in "find my iphone" i got message that its offline Although its online and all settings are OK
but it not
I'll try to turn it off and on again and see if its help
I saw in other post that recommend to turn off the location service on the iPhone and than tern it on
I will update you if it helps
thank you for your support -
Is it possible to create a configuration profile that will install multiple network printers and their associated drivers?
I was not able to find profile manager on my employer's installation of 10.6 Server. Is this only a feature of 10.7/10.8 server?10.6 server does not have profile manager, profile manager is only available in 10/7 and 10.8 server
for 10.6 server you'll need to use wgm and server admin
printer management with 10.6, I recommend you read the relevant server manuals regarding
print server and user management, printer management -
My daughter is out of the country until May. She did not take her iPhone 5 with her. Now she needs a phone number that is stored
in the memory and cannot remember her passcode. I have tried all of the possibities that she e-mailed , but none of them work
and now I am locked out for an hour each time I enter an invalid passcode. Help? How can I get around this to access the phone?Follow the instructions at http://support.apple.com/kb/HT1212
-
I just upgraded to FF7 & now when I open it none of my history or cookies are saved. I have checked in options that Firefox will remember my history and all relevant settings but it is not doing it. Is there a problem with FF7?
Can you attach a screenshot?
*http://en.wikipedia.org/wiki/Screenshot
*https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
Use a compressed image type like PNG or JPG to save the screenshot.
See also "Help About".
*Tap the Alt key or press F10 to show the Menu bar.
In current Firefox releases (29 and later) the orange Firefox menu button has been replaced by the three-bar Firefox Menu button at the far right end of the Navigation Toolbar and this button is always visible, whether you have the menu bar visible or hidden<br>A consequence of this location is that you no longer can hide the Navigation Toolbar
*There is a star like button next to the search bar on the Navigation Toolbar to bookmark the current web page and a "Show your bookmarks" button next to it to open the Bookmarks in a drop down menu.<br>You can find "Show All Bookmarks" to open the Bookmarks Manager (Library) at the bottom of this drop-down list
*If you bookmark a page then "Bookmark This Page" in the Bookmarks menu changes to "Edit This Bookmark"
*You can make the title bar visible via the "Title Bar" button at the bottom left in the Customize palette window
It is still possible to have the menu bar visible via the right-click context menu of a toolbar to have menus like the File menu with Print (Ctrl+P) and Print Preview and the Bookmarks menu available.
See also:
*https://support.mozilla.org/kb/how-to-make-new-firefox-look-like-old-firefox
*https://support.mozilla.org/kb/common-questions-after-updating-to-new-firefox
*https://support.mozilla.org/kb/learn-more-about-the-design-of-new-firefox -
I bought an ipad from some one and i can't activate it and it keeps on showing that i should type the apple id and password link to that ipad which i dont know and i can't even locate thi guy. Please help if there is a chance to activate the ipad. Thanks
There is no chance at all that you can activate the iPad without the previous user's Apple ID and password. That is the feature of iOS 7 Activation Lock.
Every time I read one of these post, I can't help but think that the user asking about this (in this case - you) was duped into purchasing a stolen device. If the seller was legit, they would have erased the device completely before they sold it. -
Hi People!
Please help...I want to know how can i get photos from ipad to the computer, that were synchronized previously to ipad but from another pc that i dont have access anymore and these pics are now only found in this ipad and no other place.Hi Alan,
Thanks for the help, but i've actually done that before.
It does not help, because it only shows the photos on the camera roll and do not show the photos synchronized with that pc that i dont have access anymore.
The photos/albums all appear on the ipad, i can see it without problems but i cant get them out of the ipad to save onto pc for backup.
And i reaaly need it, as it is the only place that i actually have these photos now... -
Network ip address keeps changing and for some reason I can't find the right settings. The diagnostics says to check with my network administrator, but idk whom that is being at a motel and all. I have made. New locations, & changed the ipv4 address. Help plz
Hmmm, is Network set to using DHCP?
Go to System Preferences
Click Network
Highlight AirPort and click Configure...
Choose “By default, join: Preferred networks”
Select your access point and Remove your access point with the minus button.
Launch your keychain access in Utilities and delete your access point keychain entry.
Reboot
Go back to the “By default, join:” page and click the plus this time to add your access point. Enter the correct password, save, reboot.
Instead of joining your network from the list, click the WiFi icon at the top, and click join other network. Fill in everything as needed -
Please help! I just sync my notes to icloud of my ipad mini but after that all notes has been covered by iphone's and all notes are missing from iPad,how could i restore it?
It's very possible that you did just as you suspect. One of the later Note file over wrote the one stored on your iPad when you synced.
When one does a sync of their iPad a backup of the iPad is created first. If that backup was still available you might be able to find the Note file there. But more than likely, if you are letting the iPad and iPhones sync on their own over Wi-Fi you have over written that back up as well. -
I have 5 apps that needed updating. I updated and now apps are "frozen" in updating stage. They won't even delete after I hit delete button. What to do?
Reset time, press and hold both the power and home buttons for 10-15 seconds till the Apple logo appears. Release both buttons. Wait 15-20 seconds till your iPad starts on it's own. Check the downloads.
-
when i was in safari one page opened and its said that my web reader is locked and i can't even shut my mac down, what should i do?
This is the Firefox Start Page that was used in Firefox 3.6 and prior versions. <br />
http://www.google.com/firefox
The '''about:home''' default homepage looks a lot like that older default homepage, but it is missing the Google menu items at the top left-side of the web page, along with the '''''Sign In''''' hyperlink for signing into Google services and the '''''Options''''' "gear button" for setting Google search preferences.
If you want the orange Firefox button to show, instead of the Menu Bar showing, you need to hide the Menu Bar by right-clicking a blank spot on the Menu Bar and de-selecting the Menu Bar by clicking on Menu Bar in that contextual menu. -
I have 2 accounts and all messages are in the same inbox, I want to separate both as with the previous OS
Hi fmethot,
What is the version of your router? Is it version 1 or 2? The Cisco 10521 is the last 5 digits of the serial number of your router. That is the default network name of your router. -
Disappointed with IOS7, i had organized my music library as per the Genre and now im unable to hear all the songs of the same genre like in the earlier versions. The options of "all albums" and "all songs" are missing in this version of IOS. Help Please..
It would be nice if you told others the steps you've tried and/or how you used to have your setup.
Anyway have you tried tapping MORE this will then bring you to
the selection-list of Audiobooks, Genres, Compilations & Composers.
Selecting Genres gives you a list of all your music split into genres which was set within the Music downloaded via iTunes or uploaded from CD or which you may have set yourself.
Then you just select the Genre you want:
If certent songs are not correctly gategorised you may need to go into iTunes and reselect via Get-info
>Info>Genre and change it there. That way you should end up with all songs of Jazz or other in 1 place. -
I have upgrade to IOS 8 and all Fotos are ereased on my Iphone and on my Computer is only the last Backup and there a no Photos now what can i do?
You really need to try this on a computer, not on the iPad.
Seeing how what is in the cloud is also on the iPad, if the content is not on the iPad, there is a good chance that the content is lost. But you can try logging into www.icloud.com in a web browser on a computer and log into your account and see if you can get into the Pages app. You may have to sign up for iCloud drive if you didn't do so already. Make SURE you that you read the blurb that will pop up in that window in iCloud for more information.
Maybe you are looking for
-
Hello everyone, I am using a anonymous user to access a especific role in my portal. Some of the iviews are km content iviews. They are html archives with navigation to other iviews. To manage to navigate from one iview to other one I use something l
-
I have a two node rac setup. One Node went down because of hardware issues. And it seems that I cannot connect from client (jdbc) when SCAN gives particular ip. I receive : ORA-12514, TNS:listener does not currently know of service requested in conne
-
Installing Oracle 11gR2 client from a batch file and it returns before done
Hello, While installing Oracle 11gR2 client on XP and 7 from a batch file. When it launches the OUI from the batch file, it returns to the batch file before the installer finishes. So, there is no way for my script to know when the installer is done,
-
Silence the camera shutter sound in an E72
Hi. I'm using a software called YBrowser to snoop around my Nokia E72 file system. I found out that the sound files for the camera shutter, auto-focus, etc. are located in the following path: z:/system/sounds/digital/relevant-sound-file-name.wav So
-
I can't find my "setting" folder on my Imac-- how do I get it back?
I can't find my "setting" folder on my Imac-- how do I get it back? I think it could be deleted