473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

calculate interest from text file with Java

Hello, I'm trying to calculate the interest from a bankaccount which is displayed in a text file as followed:
9 2 345
3 3 300
etc. (there are 19 lines in total)

the first number of each line means a day, the second stands for the month and the last for the amount of money on the account.
so the first line is Februari 9th with an amount of 345.
I want to make the program read the textfile with a Scanner. Then it should calculate for every time the balance chages the interest of 3% per year. That means we get the formula: (n/365)*(3/100) There are 365 days in a year, the months have their usual days: 31, 28, 31, 30, 31 etc.
Last, I want to print every period with it's interest and on the last line the total interest earned in that year?
I'm just a beginning programmer and would like to use arrays to solve this problem, but I don't have the experience with it to just put it in BlueJ. Actually I have no idea hwo to do that. How to make the Scanner object, how to let the program read the number: int, double?? how to calculate the interest! that's a drama for me, because I have no idea how to set this up.
So if someone could help me... Thank you.
Oct 14 '06 #1
2 3308
r035198x
13,262 8TB
Hello, I'm trying to calculate the interest from a bankaccount which is displayed in a text file as followed:
9 2 345
3 3 300
etc. (there are 19 lines in total)

the first number of each line means a day, the second stands for the month and the last for the amount of money on the account.
so the first line is Februari 9th with an amount of 345.
I want to make the program read the textfile with a Scanner. Then it should calculate for every time the balance chages the interest of 3% per year. That means we get the formula: (n/365)*(3/100) There are 365 days in a year, the months have their usual days: 31, 28, 31, 30, 31 etc.
Last, I want to print every period with it's interest and on the last line the total interest earned in that year?
I'm just a beginning programmer and would like to use arrays to solve this problem, but I don't have the experience with it to just put it in BlueJ. Actually I have no idea hwo to do that. How to make the Scanner object, how to let the program read the number: int, double?? how to calculate the interest! that's a drama for me, because I have no idea how to set this up.
So if someone could help me... Thank you.
There is no point in giving you code to do all of this since you said you are new to programming. I'd suggest you look around for how to use the scanner first. Once you've had a good look at it and some examples of how to use it, you may actually be able to complete this without further help
Oct 16 '06 #2
I know how to use the Scanner. THis is my code:
Expand|Select|Wrap|Line Numbers
  1. try 
  2.         {
  3.         String file = "saldo_overzicht.txt";
  4.         Scanner input = new Scanner(new FileReader (file)); 
  5.  
  6.         int value = 0;
  7.         value = input.nextInt();  /** Read first number from each line: day of month */
  8.  
  9.         while(data_days[countdays] != 31 && data_months[countmonths] != 12)
  10.             {
  11.                 data_days[countdays] = value;  /** Store day in data_days Array  */
  12.                 countdays ++;
  13.  
  14.                 value = input.nextInt();            /** Read second number from each line: month */
  15.                 data_months[countmonths] = value;   /** Store month in data_months Array  */
  16.                 countmonths ++;
  17.  
  18.                 value = input.nextInt();            /** Read third number from each line: balance */
  19.                 data_amount[countamount] = value;   /** Store amount in date_amount Array  */
  20.                 countamount ++;
  21.  
  22.                 value = input.nextInt();            /** Read first number from each line. */
  23.             }
  24.         } 
  25.         catch (Exception e) { }    
  26.  
I also created the arrays needed to store the numbers read.
I would like to know how to solve the other problem: calculate interest with months of 31, 28, 31, 30, 31 days etc...
Oct 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
86
by: Michael Adams | last post by:
I don't know if you have noticed, but it seems like Microsoft is losing interest in C#, and putting their energy into Visual Basic.NET instead. For instance, online chats by language since July...
4
by: Klaus Jensen | last post by:
Hi! I am currently converting an ASP/SQL Server application to VB.Net/Access. The application performs calculations based on which products are selected. Therefore i need to be able to store...
13
by: Martin Herbert Dietze | last post by:
Hi, I need to calculate the physical length of text in a text input. The term "physical" means in this context, that I consider 7bit-Ascii as one-byte-per character. Other characters may be...
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
2
by: chrisb1586 | last post by:
Hey guys I have no idea with what im doing with loops( a for, do, or while loop any of the 3) or the logic on how to do this and i have to have this done for school tommorow. I have to create a...
7
by: carterweb | last post by:
This is how I do it now. 1. Determine the dimensions of the rectangle. 2. Set a my font size to a fixed maximum size. 3. Apply the font my string and measure the string using the graphics...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.