473,698 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculate interest from text file with Java

9 New Member
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 3327
r035198x
13,262 MVP
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
foleyflint
9 New Member
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
9989
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 number. That number will appear in a seperate box at the bottom. So basically whatever you choose has a corresponding number associated with it (except for the text input, which you enter whatever number) and those numbers are added and produced in...
53
5717
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 difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
86
3614
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 1, 2004: VB.NET 47 C# 6 C++ 8 J# 0
4
9956
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 formulas in the database, replace placeholdes with values and execute the calculation. Earlier this was done by executing the formula on SQL Server and retrieving the result, but that is no longer possible - or desireable for that matter.
13
14261
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 longer, e.g. cyrillic would be 2 bytes per character. Is there a safe and easy way to notice non-7bit-Ascii input? Cheers,
6
14446
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 letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
2
2084
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 windows app with 4 text boxes for starting balance, number of years, interest rate %, and what you will have which is a read only. One calculate button to do this all. heres what i have now all and any help is much appreciated thanks because i really...
7
43912
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 object. 4. If string size is less than the size of the rectangle, we are done.
0
10766
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.