Displaying Perfect Numbers and Factors in JTextArea box
I had to write a program that displays the perfect numbers along with their factors in a scrollable JTextArea Box. I have my program written but when it displays the output all that appears is
Number Factors
in my box with no numbers of factors listed. If anyone can help me with this problem please respond...here is my program so far
public class Perfection
public static void main (String args [])
String output, factor;
long min, max, factors, sum, lowerBound;
JTextArea text = new JTextArea (30,50);
JScrollPane scroll = new JScrollPane (text);
sum = 0;
output = " ";
factor = " ";
output += "Numbers\t" + "Factors";
min = Long.parseLong (JOptionPane.showInputDialog ("Enter the lower bound of your range"));
max = Long.parseLong (JOptionPane.showInputDialog ("Enter the upper bound of your range"));
while (min > 0 && max > min)
for (lowerBound = min; lowerBound <= max; lowerBound++)
for (factors = 1; factors < lowerBound; factors ++)
if (lowerBound % factors == 0)
factor += factors + ", ";
sum += factors;
if (lowerBound == sum)
output += "\n";
output += lowerBound + "\t" + factor;
text.setText (output);
JOptionPane.showMessageDialog (null, scroll, "Range of " + min + " to " + max, JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog (null, "Restart program and enter a range in which the lower bound is positive and the upper bound is greater than the lower bound",
"Range of " + min + " to " + max, JOptionPane.WARNING_MESSAGE);
System.exit (0);
}
I answered your question, look
http://forum.java.sun.com/thread.jsp?forum=31&thread=500915&tstart=0&trange=15
Similar Messages
-
MYWAY articles displayed as numbers and letters
Recently out of the blue my MYWAY homepage articles started appearing as underlined numbers with a few letters, instead of news headlines. This only happens in Safari. I have OS 10.7.3 and the latest version of Safari. I uninstalled, and reinstalled Safari to no avail. I have used myway as a homepage for years and want to continue to. Any suggestions would be appreciated.
Please read this whole message before doing anything.
This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
Step 1
The purpose of this step is to determine whether the problem is localized to your user account.
Enable guest logins and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
Test while logged in as Guest. Same problem(s)?
After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. Create a new account in which to test, and delete it, including its home folder, after testing.
Step 2
The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. The instructions provided by Apple are as follows:
Be sure your Mac is shut down.
Press the power button.
Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
Test while in safe mode. Same problem(s)?
After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2. -
Where is the redemption code located on product elements 13. There are numbers and characters on the box and on the cd sleeve.
Or even in a prepaid card as per this picture:
Click on the image and get the necessary instructions how to redeem it to get proper serial number. -
If I have to validate Outlook on PC or Mac - I have no problem - the random numbers and letters display fine - but if I am requested to validate outlook before sending a mail when using my iPad, the operation fails as the test numbers and letters are not shown - only a snap blue box with a question mark. How do I convert the box into the image of a new validation code? Thanks in advance.
Hello,
The question mark means it can't find it where it was when you put it in the Dock.
I'd get EasyFind...
http://www.macupdate.com/info.php/id/11076
Use it to search your whole drive for Files & Folders, case insensitive & show invisibles...
Complete
That will show any with that word in the name at all. -
Hi, i'm new using numbers, and when I try to open a excel file don't let me do it, instead appears a box whit a error and close app, any help?
What does the error say?
A couple of thoughts: the file is corrupted or is password-protected. Corruption is more likely to cause Numbers to crash & Numbers cannot open password-protected Excel files. Try using one of the free Office clones & see what happens. -
I just upgraded to ios 6 on my iphone 3gs and I noticed on a couple of incoming emails that the images and information are not being displayed. There is a blue square box with a blue question mark inside. I already tried to press the home key and power key to restart. The email still does not display correctly. I went on my laptop to retrieve that same email and I was able to see the graphics and information, so the problem is on the iphone. I received two emails like this, so I'm missing all the important information. I also tried to retrieve my email through the internet browser and I still have the same problem. Any suggestions? Thanks!
I forgot to mention that I have an Ipad 2 also and I can view the email information on there also. I received an email from Party city and it said to click here to print out the coupon. So I click the coupon and there is the little blue box with the question mark. This is the first time I've seen this happen, as I have printed out the coupons before. Maybe it has to do with the IOS6 update, because this just started to happen right after the update.
-
Apple macbook pro with retina display is having yellow screen problems in which screen is not perfectly white and is yellowish. More over the service frm apple's part is ridiculous as they have faulty spare part. Does ne1 hv email of senior person?
Apple service centre employee told me that they do not have this 14 day offer in India.
And My mac book pro is taken in by Service centre people to run test etc and I will be informed the next day if they accept it as a fault or not ?
I feeling ridiculously bad. -
Boxes with numbers and letters show instead of certain images on some websites
On yammer.com and linkedin.com, images for icons, like those that should display along the top of the screen do not display. Instead, I see a rectangle with numbers and letters. I've seen quite a few articles about the rectangles with numbers and letters that apply to characters but none involving images. I've also tried the steps in the article on troubleshooting images not displaying properly, and nothing seems to work.
Thanks!Make sure that you allow pages to choose their own fonts.
*Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above" -
Keynote, Numbers and Pages are displayed as Top Free, but charges fee.
Hi All,
In the first page of Appstore Keynote, Numbers and Pages are displayed as Top Free. But when I try to get them from AppStore it charges fee. How can I get them free?
Thanks in advance.Asked and answered at least a dozen times in this forum in the last week. Please always do a search before posting.
The iWork apps are currently free to some folks who qualify.
If someone bought a new Mac since ! OCT 2013, iWork is free.
If someone owned the previous version of iWork and upgraded to OS X Mavericks 10.9, the newest version of iWorks for Mavericks is free.
Otherwise, these are usually paid apps. -
I am facing problem regarding graphical user interface. I am using text box for editing files. I want to show the line numbers and graphical breakpoints along with text box. Can anybody help me in this? Thanks.
Thanks for you reply.
But actually I don't want to show the \ (backslashes) to the user in my text box.
Ok let me elaborate this problem little more.
I want to show my text box as it is in normal editors e.g. In Matlab editor. There is a text box and on left side the gray bar shows the line numbers corresponding to the text. Further more i want that the user should be able to click on any line number to mark specific line as breakpoint (red circle or any graphical indication for mark).
Regards,
Waqas Ahmad -
The validator gives me error messages messages that refer to line numbers and positions - very unhelpful. I need to be able to display the line numbers in the reader to find the places where the errors are. Can anybody point me in the right direction? MUch appreciated. Earl
Adobe Reader can't display epub files. Adobe Reader can't display line numbers.
-
BP Catalog numbers and Item Codes Display
Hello
Is there any way that BP catalog numbers and item codes can be display together.
Or is there any work around available.
I have a client who wishes to use i.e view both the item code and the BP Cat Number on their screen..,
we create a formatted search and this worked.
However the purchase orders which are automattically generated through another Add-on cant use a formatted search to work.
Thanks for your help in advance.
DDear Darpal,
Kindly check note 1059015 which describes the workaround to display both Item Number and the Business Partner.
Regards,
Varun
SAP Business One Forum Team -
Formatting numbers and align the display
How do you line up number when using NumberFormat function.
ie. The following code displays a positive and a negative
number that are both right justified:
xx33,456
(33,456)
(note: xx is used to demostrate spaces here, it does not show
up in the output)
<tr><td
align="right">#NumberFormat(33456,"(9,999)"
)#</td></tr>
<tr><td
align="right">#NumberFormat(-33456,"(9,999)"
)#</td></tr>
As you can see both lines or numbers are flushed to the right
and the numbers don't line up.
I need to have the numbers line up as follows:
x33,456
(33,456)
(again I used x as space here)
I can not use an extra space since the width of space is
different than ')'
I tried adding "<font color=white>)</font>" ie. a
white ')' at the end of positive numbers but that does not work
either.
Any suggestions?
Thank you in advance.
[email protected]Thank you very much for responding to my question.
Unfortunately CELLPADDING and/or CELLSPACING can not be 0
since it is a very complex reporting format.
If I set them to 0 then I have to add bunch of extra blank
columns to compensate for that.
Any other suggestions?
I believe MS Word and Adobe writer have a tab or a formatting
style specifically for this purpose.
Has anyone explored writing a custom tag or a script maybe to
call adobe pdf API to utilize pdf writer's formatting capability?
I can't believe I am the first person requiring to do this.
Hopefully when we come up with an answer everyone can
benefit.
Thanks again.
Looking forward to more respond, please!!! -
Hey guys!
So my Macbook started acting weird a couple of months ago. All of a sudden i could only write in capitol letters and i couldnt write any numbers. Every time i tried to write a number, i would only get the symbols instead such as " "#¤%&/ " etc. I tried restarting it and the computer booted in safe mode and still had the same problem as before. I decided to read around some forums and someone suggested " zapping the PRAM" which i did and it fixed the problem for about 1-2 days and then it was back to the normal.
I decided to turn in my computer to an authorized Apple technician to take a look at it and after a few days i got a phonecall saying that he had run tests for 6 hours but couldnt figure out what was wrong with the computer, he just knew that something was wrong. When i got the computer back it was working perfectly but the weird thing is that every now and then the same thing would happen with the keyboard and the weirdest part is that it usually stopped working on fridays, once a week.. Anyways i have done all i can, now im turning to you guys for some much appriciated help.
Any suggestion on how to fix this problem of mine?Actually it sometimes gets a little further, the display will dim and the pointer will appear and then whoop it will turn off. if i do a verbose start up, it will finish all the steps, the white screen will appear and dim and then it will turn off.
-
First of all I have to say the tutorials on this site are extremely helpful. My instructor wants all our java code written as Object Oriented and when I did a search on here for Object Oriented it totally helped out. Now I just need help with the display of numbers, my code works perfectly fine except that the number has wayyyyyyyyyyy to many decimal points after it. I only wanted two.
public class Mortgage
double mtgAmount;
double mtgTerm;
double mtgRate;
double monthPymt;
public void Amount(double newValue)
mtgAmount = newValue;
public double Amount()
return mtgAmount;
public void Term(double newValue)
mtgTerm = newValue;
public double Term()
return mtgTerm;
public void Rate(double newValue)
mtgRate = newValue;
public double Rate()
return mtgRate;
public void calcmonthPymt(double newValue) //(LoanAmt * Rate) / (1- Math.pow(1+Rate,-Term));
monthPymt = (newValue);
public void display()
System.out.println ("The Mortgage Amount is:" +(Amount( ) * Rate( )) / (1- Math.pow(1+Rate( ),-Term( ))));
public static void main (String[] args)
Mortgage Mortgage1=new Mortgage();
Mortgage1.Amount(200000);
Mortgage1.Term(360);
Mortgage1.Rate(.0575);
Mortgage1.display();
}I figured it out, the math is wrong I think but I got everything to display correctly
import java.io.*;
import java.text.*;
import java.text.DecimalFormat;
public class Mortgage
double mtgAmount;
double mtgTerm;
double mtgRate;
double monthPymt;
DecimalFormat money = new DecimalFormat("$0.00");
public void Amount(double newValue)
mtgAmount = newValue;
public double Amount()
return mtgAmount;
public void Term(double newValue)
mtgTerm = newValue;
public double Term()
return mtgTerm;
public void Rate(double newValue)
mtgRate = newValue;
public double Rate()
return mtgRate;
public void calcmonthPymt(double newValue) //(LoanAmt * Rate) / (1- Math.pow(1+Rate,-Term));
monthPymt = (newValue);
public void display()
monthPymt = (Amount( ) * Rate( )) / (1- Math.pow(1+Rate( ),-Term( )));
System.out.printf("The payment amount is:$%.2f", monthPymt);
System.out.println();
public static void main (String[] args)
Mortgage Mortgage1=new Mortgage();
Mortgage1.Amount(200000);
Mortgage1.Term(360);
Mortgage1.Rate(.0575);
Mortgage1.display();
}
Maybe you are looking for
-
I've entered my new password many times and exchange tells each time that either my account name or password is incorrect. I deleted my account from exchange and re-set it up, no help. I rebooted the phone, no help. Gmail works just fine on my lap
-
I got switched to Verizon via the Alltel buyout so I'm not really sure how all this works with Verizon. I have a BlackBerry Storm and want to switch to a Droid. I have had my BlackBerry for a year and a few months. I am about 6-8 months away from NET
-
Script Error, Continue?"
When I launch Media Center Deluxe II I have this error: Script Error, Continue? I download the patch but the error persist. I have a windows 2000 with a FX5200 Thx a lot.
-
I am out of town and trying to use my personal hotspot. Ever since I updated to OS 5 I have had this problem. When I disconnect in windows 7, I can not reconnect withouth messing with settings. When it does connect it creates a new homegroup so my
-
I have a disc for Photoshop CS-6 and entered the redemption code; system says I'm all set and a serial number is not needed. Install program on disc will not proceed without serial number. How do I resolved this Catch-22?