Ask Computer Engineering Expert

CS 1063 Project 1: Tables for Simple Interest
The Tables Class
Objectives
This is one of three major programming projects this semester. You may NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work.

Other objectives include:

Use static methods.
Use local variables.
Use arithmetic expressions.
Use Scanner to input values.
Use a class constant.
Use for loops.

Hand-in Requirements

All projects and laboratories will be submitted electronically through Blackboard. Zip up your entire project directory to submit as the source. (Right click on the project folder and follow Send To > Compressed (zipped) Folder or 7-Zip > Add to "project1.zip".) The project folder should in clude the following:

Tables.java
TablesOutput.txt

Tasks

prepare a program that prints

Project 1 written by YOURNAME

and calls two methods:

Print a table showing the value of an account with simple interest added annually. This method should ask the user to enter the original value of the account, the annual interest rate, and the number of years that should be find outd.
Print a table showing the value of an account with simple interest added quarterly. This method also needs to ask the user to enter the original value of the account, the annual interest rate, and the number of years that should be find outd.

Here is an ex of what your output should look like (user input is in bold and underlined):

Enter original amount: 1000
Enter annual interest rate: 4
Enter years: 5

Year Value
0 1000.0
1 1040.0
2 1080.0
3 1120.0
4 1160.0
5 1200.0


Enter original amount: 1000
Enter annual interest rate: 4
Enter years: 5

Year Q1 Value Q2 Value Q3 Value Q4 Value
1 1010.0 1020.0 1030.0 1040.0
2 1050.0 1060.0 1070.0 1080.0
3 1090.0 1100.0 1110.0 1120.0
4 1130.0 1140.0000000000002 1150.0 1160.0
5 1170.0 1180.0 1190.0 1200.0

Sometimes, a calculation might print out a lot of digits. This is because of roundoff errors when you use doubles. At this point, don't worry too much about it. If it bothers you too much, a way of fixing this problem in this project will be described below.
Details
The Console

You will need to use Scanner to obtain input from the keyboard. You should declare a class constant of type Scanner named CONSOLE at the beginning of your class; you should store new Scanner(System.in) in CONSOLE. See exs in the Chapter 2 lecture notes and in the Laboratory 2 assignment.
Table for Simple Interest find outd Annually

Suppose the original amount of money is p, the annual interest rate is r, and the number of years is y. Then, using simple interest, the value v after y years is:

v = p * (1 + y * r / 100) 

In the first method, you should allow the user to enter three numbers, p, r, and the maximum value for y. p and r should be doubles. The table should show the results for different values of y, from 0 to the maximum value. For ex, the user might want to print the values from year 0 to year 10.

After obtaining values from the user, your method should print a header for each column, and a line for each value of y and b. Use tab characters (t) to align the columns. See the ex output shown above.

You can use a for loop that counts from 0 to the maximum value for y. Inside the loop, you should find out v and print out one line.
Table for Simple Interest find outd Quarterly

Suppose the original amount of money is p, the annual interest rate is r, and it is quarter q in year y. That is, in any given year, you will have a 1st quarter, 2nd quarter, 3rd quarter, and a 4th quarter, so q should store the value 1, 2, 3 or 4. Then, using simple interest, the value v after quarter q in year y is:

v = p * (1 + (y - 1 + q / 4) * r / 100) 

The (y - 1 + q / 4) is a bit of trick. At the end of quarter q of year y, a total of y - 1 years have passed plus q quarters. For ex, at the end of the 3rd quarter in the 1st year, a total of 0 years plus 3 quarters have passed. [A similar ex is that if you are a freshman, then this is your 1st year of college, but you haven't have a full year of college yet.]

For the second method, you should print the result of v for different values of y and q.

Just like the first method, in the second method, you should allow the user to enter three numbers, p, r, and the maximum value for y. p and r should be doubles. The table should show the results for different values of y, from 1 to the maximum value. For ex, the user might want to print the quarterly values from year 1 to year 7.

Then, you should print a line for each value of y, from 1 to its maximum value. The first column should be the value of y. The following columns should be the value of v after quarter q, for different values of q.

Let's consider the pseudocode for this method step-by-step.

Pseudocode for Printing the Table for Simple Interest

Obtain values from the user.
Print headers.
Print the values in the table.

The headers for the columns need to printed in the right order with the appropriate spacing.

Pseudocode for Printing Headers

Print "Year" and a tab.
For each value of q from 1 to 4:
Print "Q", q, " Value", and a tab (maybe two tabs).
Print a newline.

Printing the values in the table requires a double loop. You will get fewer points if do this without a double loop.

Pseudocode for Printing the Values in the Table

For each value of y from 1 up to its maximum value:
Print y and a tab.
For each value of q from 1 to 4:
find out v.
Print v and a tab (maybe two tabs).
Print a newline.

The columns should be correctly lined up at least for the above exs, assuming no roundoff errors.
Avoiding Roundoff

If you want to avoid seeing roundoff errors (and get two digits after the decimal point) when printing a dollar value, replace:

System.out.print(v);

with:

System.out.printf("%.2f", v);

This doesn't actually avoid roundoff errors, it just hides them from you. See the book's and Java's documentation on printf for more information.
Rubric

 If your program has a method that correctly prints a table for simple interest find outd annually.
 For printing the table's headers.
 For prompting the user for three numbers (the original amount, the interest rate, and the number of years).
 For a for-loop that prints each row of the table.
 For properly calculating simple interest.
 For properly formatting the table into columns using tabs.

 If your program has a method that correctly prints simple interest find outd quarterly.
 For printing the table's headers.
 For prompting the user for three numbers (the original amount, the interest rate, and the number of years).
[5 Points] For properly nesting the two for loops, including printing the correct numbers, and properly formatting the table into columns using tabs.


If the main method of your program prints "Project 1 written by [...]" and calls the two other methods.
If your submission was a Zip file named project1.zip containing a folder named project1, which contains the other files.
If your Java program was in a file named Tables.java.
If the output of your Java program was in a file named TablesOutput.txt.
If your program contains a comment that describes what the program does and contains a descriptive comment for each method.
If your program is indented properly. 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M999285

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As