Expert Answer:Basic Java Programming

  

Solved by verified expert:Finish the starter code based on the prompt requirements. The code should be able to compile and run correctly. Mainly is about loop practice to print.
programming_assignment_3.pdf

loops.zip

Don't use plagiarized sources. Get Your Custom Essay on
Expert Answer:Basic Java Programming
Just from $10/Page
Order Essay

Unformatted Attachment Preview

Programming Assignment 3
Due: 11:59pm, Wednesday, January 23rd
Overview:
The goals of this assignment are:
1. To become comfortable with using flow control and loops;
2. To focus on programming style and semantics;
3. To program various algorithms using only loops and if statements
Note: it is important that your program returns a string formatted exactly as it is in the
examples.
Setup:
Start by logging onto your ieng6 account. Then create and enter your source directory:
$​ mkdir ~/PA3
$​ ​cd​ ~/PA3
Download your ​starter files​ and copy them to your source directory on ieng6.
How to test your code:
To test your code, you will want to compile the file you are working on and then run it. Doing this
is simple but important for you to understand.
$​ c
​ d​ ~/PA3
$ j
​ avac ​.java
+You have just used the java compiler to compile your code into a class file that the Java Virtual
Machine (the computer) can understand. You should now see ​.class​ in your
directory. Now you need to run it.
$​ ​java​
This executes your file by entering the ​main​ function in the file. You can change the inputs to
your algorithm by changing the code in the ​main​ function. Note that you don’t specify any file
extensions (neither .class nor .java) when using the ​java​ command.
Also, as usual, upon submission to gradescope, your code will be tested and the results will be
displayed to you. Please be aware that these test cases are basic and are not comprehensive.
They do not cover any corner cases. However, the test cases we grade your submissions with
will test for these corner cases. It is advised that you write your own test cases to ensure that
your code can handle the corner cases. It is up to you to figure out what the corner cases are.
IPattern Interface:
You will notice that every java file, with the exception of MostChar.java, implements an interface
named ​IPattern.​ Use the functions provided by this interface to implement your functionality.
Namely, ​printPattern​ should return the pattern containing the appropriate number of lines;
printNthItem​ should return only the Nth line in the pattern; and ​setParam​ can be used to set any
global variables you’d like to use. ​Do not change the IPattern interface or any of the method
signatures (the method visibility, name, and parameters) as we will be using this
interface to grade your submission.
Problem 1: ASCII Staircase (10 points)
Using for-loops, develop an algorithm that returns a String formatted as a staircase using the
character ‘x’ (lower case). The staircase should have the following properties:
● N steps going up from left to right
● The top step should have one ‘x’, the second step from the top have two ‘x’s, the third
step from the top should have three ‘x’s, … , the bottom step should have N ‘x’s.
○ Generally, the ​nt​ h step from the top should have ​n​ ‘x’s
Example output for ​N = 10​:
_________x↩
________xx↩
_______xxx↩
______xxxx↩
_____xxxxx↩
____xxxxxx↩
___xxxxxxx↩
__xxxxxxxx↩
_xxxxxxxxx↩
xxxxxxxxxx↩
Note​: the underscores (“_”) should be spaces (“ “) and the arrows (“​↩​”) should be replaced with
carriage returns. I’ve included them here to draw attention to the fact that there should be
spaces preceding the step. Your output has to ​exactly​ match the specifications to be
considered correct.
Problem 2: Fibonacci Sequence (10 points)
Develop an algorithm that returns a String of the first N terms of the Fibonacci Sequence. For
information on the characteristics of the sequence, you may rely on our guiding light, ​Wikipedia.
You may use any kind of loop you want, but you may not solve this problem recursively.
Example output for ​N = 11​:
0_1_1_2_3_5_8_13_21_34_55
Note​: As in Problem 1, the underscores (“_”) should be spaces (“ “). I’ve included them here to
draw attention to the fact that there should be spaces between the numbers, and there
shouldn’t​ be any spaces ​after the last number​.
Problem 3: Multiplication Table (10
points)
Develop an algorithm that returns a String formatted as the multiplication table of ​N​ from 1 up to
and including ​X​. You can assume ​N​ will be a whole number and won’t be large enough to cause
overflow. You can assume that ​X​ will be a positive whole number greater than or equal to 1
Example output for ​N = 7, X = 9​:
7_*_1_=_7↩
7_*_2_=_14↩
7_*_3_=_21↩
7_*_4_=_28↩
7_*_5_=_35↩
7_*_6_=_42↩
7_*_7_=_49↩
7_*_8_=_56↩
7_*_9_=_63↩
Note​: As in previous problems, the underscores (“_”) should be spaces (“ “) and the arrows (“​↩​”)
should be replaced with carriage returns. I’ve included them here to draw attention to the fact
that there should be spaces between the characters. There should also be a newline after the
last line.
Problem 4: Character Frequency (10
points)
Develop an algorithm that loops through a given string ​S​ and returns the character that occurs
most frequently. You can assume ​S​ contains at least 2 characters and only contains lowercase
letters in the English alphabet. If there are more than one characters with the highest frequency,
return the character that occurs first in the string.
Example output:
S = “abcaadddb”
Return: ‘a’
Note:​ while both ‘a’ and ‘d’ occur 3 times, we return ‘a’ because it occurred first in the string.
Problem 5: Pascal’s Triangle (25 points)
Develop an algorithm that returns a String pattern of Pascal’s Triangle of size N. For more
information on Pascal’s Triangles, look ​here​.
Example output for N = 9:
________________1
______________1___1
____________1___2
1
__________1
3
3
1
________1
4
6
4
1
______1
5
10 10 5
1
____1
6
15 20 15 6
1
__1
7
21 35 35 21 7
1
1
8
28 56 70 56 28 8
1
Note:​ there are three spaces between each number in a given line. I’ve included the
underscores here to highlight that. The underscores to the left of the 1s denote spaces that’s
necessary to make the numbers look like a triangle.
Problem 6: Triangular Square (25 points)
Develop an algorithm that returns a String pattern of a “triangular square” with N lines. For this
problem, describing the desired result is difficult, so instead we provide two examples of what
your program should return. These examples can be found in the comments of the starter code.
To help you understand the construction of the “triangular square”, imagine a vertical line that
splits the square into a left- and right- half. You can see that the two halves are mirror images of
each other. Pay attention to the number of stars and spaces on either side of the line. Come up
with a rule (ie, “for line N, there are x stars and y spaces”) and then implement that.
Style Guide (10 points)
Make sure to read the style guidelines provided ​here​. These guidelines for style will have to be
followed for all the remaining assignments. Read them carefully. A brief summary is provided
below.
● Use reasonable comments to make your code clear and readable.
● Use class header and method header block comments to describe the purpose of your
program and methods.
● Use reasonable variable names that are meaningful.
● Judicious use of blank spaces around logical chunks of code makes your code much easier to
read and debug.
● Keep all lines less than 80 characters. ​(​If the starter code exceeds 80 characters per line,
you can leave it as is​)
● Use 2-4 spaces for each level of indentation. If you use emacs, it will automatically add
appropriate spaces/tabs to line up indentation. If using vi or vim, use spaces to make sure each
level of indentation lines up evenly.
● Every time you open a new block of code (use a ‘{‘), indent farther. Go back to the previous
level of indenting when you close the block (use a ‘}’).
● Always recompile and run your program right before turning it in, just in case you
commented out some code by mistake.
Turnin Instructions
Remember the deadline to turn in your assignment is Wednesday, January 23, by 11:59 pm.
You’ll be turning in your files on ​Gradescope​.
You’ll be submitting ​8 files​ – Staircase.java, Fibonacci.java, MultTable.java, MostChar.java,
PascalTriangle.java, TriangularSquare.java, IPattern.java and README.md
You will need to create your own README.md, this is not provided to you.
Do not zip your files or submit any other files besides the files listed above.
You can submit as many times as you want before the deadline. The latest submission will be
considered for evaluation.

Purchase answer to see full
attachment

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

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.

Money-back guarantee

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

Zero-plagiarism guarantee

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

Free-revision policy

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

Privacy policy

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

Fair-cooperation guarantee

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

Order your essay today and save 30% with the discount code ESSAYSHELP