Do the following two programs:
The program must have the following structure:
For output, you should build a formatted string which includes tabs and new lines to represent your table. JOptionPanes by themselves are not capable of properly formatting tabs. However, there is another Java class which can be used with JOptionPanes to correctly display a formatted string. TheJTextArea class understands all string formatting instructions. The following illustrates how to use the JTextArea class with a JOptionPane to display a formatted string.
String output = “This t is t a t formatted t string. n”;
// Create a new JTextArea object
JTextArea area = new JTextArea( );
// Place a formatted string into the JTextArea
area.setText( output );
// Place the text area into the JOptionPane
JOptionPane.showMessageDialog( null, area, “Title for dialog box”, JOptionPane.INFORMATION_MESSAGE );
For each of the two programming problems, create an Eclipse project and develop a Java program to solve the problem. Make sure to capture a sample of your program’s output. The best way to do this is to click on the console window you want to capture and then press the Alt and PrintScreen keys at the same time.Then paste your captured screen image into a Word document. For each of the two programs, put the screen capture followed by a copy of your source code into your Word document.
Random Numbers in Java
There are two different classes available to generate random numbers in Java. The static method random from the Math class can be used to generate a random floating point number from 0 up to but not including 1. This number can be scaled to whatever range of random numbers is desired.
(int)(Math.random( ) * 10); //results in an integer between 0 and 9
The Random class from the java.util package can also be used to get random numbers. The nextInt method returns an integer from 0 up to but not including the argument value provided to the nextInt method.
Random rand = new Random( );
int number = rand.nextInt(10); //results in an integer between 0 and 9
minimumValue + differenceBetweenValues * rand.nextInt( scalingFactor )
The formula shown above is used to generate a range of random numbers starting at some minimum value and generating some specified number of random values. The scalingFactor determines how many different random values will be generated by the call to nextInt, starting with the value 0. The difference between values is usually 1.
Your final programming document should contain in the following order:
1. Screen capture of the first program followed by source code.
2. Screen capture of the second program followed by source code.
3. Submit this as the Week 1 Programming Solution.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more