473,289 Members | 1,840 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,289 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 3304
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.