Homework2
Note: Submit your work (upload the .java source code files ONLY, not the compiled .class files!) through the “Homework2” link on Brightspace. You may submit an unlimited number oftimes; we will only grade the last/latest submission attempt, but be sure to attach all of your files
to each submission attempt. Be sure to include your name and Stony Brook ID number in acomment at the beginning of each file that you submit.Due: Thursday, October 10, 11:59pm Total: 25 points (5 points per problem)
Submission Instructions: Name your java classes for this assignment as:
Problem1: Pyramid.java
Problem2: Interests.java
Problem3: LongestCommonPrefix.java
Problem4: PerfectNumber.java
Problem5: ArmstrongNumbers.java
- Pyramid.java: (Printing numbers in a pyramid pattern) Write down a program in Java with anested for loop that prints the following output (powers of 2) for any number of lines:Here is a sample run:Enter the number of lines: 8
Output:
1
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
1 2 4 8 16 32 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
- Interests.java: (Financial application: comparing loans with various interest rates) Write aprogram that lets the user enter the double loan amount and loan period in number of years(int) and displays the monthly and total payments for each interest ratestarting from 5% to 8%,with an increment of 1/8.Here is the sample run:Loan amount: 10000.00
- Number of years: 5
Interest Rate Monthly Payment Total Payment
标签:Interests,Pyramid,java,16,number,limit,numbers,Enter,ArmstrongNumbers From: https://www.cnblogs.com/comp9021/p/18442741