Forum Moderators: open

Message Too Old, No Replies

Current Account

         

java_junkie

7:08 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



I have been working on this for a while now but it isn't prompting:

<script type="text/javascript">
var bankNamesArray = Pennygo Bank, Cardew Bank, Summer Bank;
var currentArray = [2.0,1.5,1.8,0,0,0,0,0,0,0];
var savingsArray = [4.0,3.75,4.75,0,0,0,0,0,0,0];
var eSavingsArray = [4.5,4.75,4.2,0,0,0,0,0,0,0];
var bankArray = new Array(10);
var userNumber;

function addInstitution ()
{
bankNames = window.prompt('Please enter the name of your bank ', 'bankNamesArray')
current = window.prompt('Please enter your Current account rate ', "")
userNumber = parseFloat(userInput);
savings = window.prompt('Please enter your Savings account rate ', "")
userNumber = parseFloat(userInput);
eSavings = window.prompt('Please enter your eSavings account rate ', "")
userNumber = parseFloat(userInput);
};

function displayRates()
{
for (var bank = 0; bank < bankArray.length; bank = bank + 1)
document.write(bankNamesArray[bank] + ' : ' + currentArray[bank]'<BR>' + savingsArray[bank]'<BR>' +eSavingsArray[bank]'<BR>')
};

// Main program starts here

addInstitution();

display();

document.write('<BR><BR><BR><BR>');

response = window.prompt('Do you want to calculate the interest on an amount of money (Y/N)? ','');
while(response == 'Y' ¦¦ response == 'y')
{
amountInPounds = window.prompt('Enter amount in Pounds ','');
interest = calculateInterest(amountInPounds);
document.write('£ '+ amountInPounds + ' attracts £' + interest + ' interest');
document.write('<BR><BR><BR>');
response = window.prompt('Do you want to calculate the interest for another amount (Y/N)? ','')
}
</script>

DrDoc

7:11 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var bankNamesArray = Pennygo Bank, Cardew Bank, Summer Bank;

That should probably be:

var bankNamesArray = new Array('Pennygo Bank', 'Cardew Bank', 'Summer Bank');

java_junkie

7:16 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



still the same thing Doc please I need your help on this I am been on it for 2days now I had no choice but to ask for help

DrDoc

7:26 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All your arrays should be in the same format.

arrayname = new Array(value1, value2, value3);

java_junkie

7:59 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



var bankNamesArray = new Array('Pennygo Bank', 'Cardew Bank', 'Summer Bank');

Aren't they because they all have Bank in front of them

Greven

8:11 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Here's some working code, but I had to guess a lot at what you were trying to accomplish.

For example, you prompt current account rate, savings account rate, and esavings rates but you don't do anything with the values you get.

Further to that, you were referencing 10 elements and trying to print the values from the arrays above, but you only had 3 values in the bank names.

Hope this help, and if you need further help just clarify what you're trying to accomplish.


<html>
<head>
<title>Testing</title>
<script>
var bankNamesArray = new Array("Pennygo Bank", "Cardew Bank", "Summer Bank");
var currentArray = new Array(2.0,1.5,1.8,0,0,0,0,0,0,0);
var savingsArray = new Array(4.0,3.75,4.75,0,0,0,0,0,0,0);
var eSavingsArray = new Array(4.5,4.75,4.2,0,0,0,0,0,0,0);
var userNumber;

function addInstitution()
{
bankNames = window.prompt('Please enter the name of your bank ', bankNamesArray)
current = parseFloat(window.prompt('Please enter your Current account rate ', ""));
savings = parseFloat(window.prompt('Please enter your Savings account rate ', ""));
eSavings = parseFloat(window.prompt('Please enter your eSavings account rate ', ""));
};

function displayRates()
{
for (var bank = 0; bank < bankNamesArray.length; bank++)
document.write(bankNamesArray[bank] + ' : ' + currentArray[bank] + '<BR>' + savingsArray[bank] + '<BR>' +eSavingsArray[bank] + '<BR>');
};

// Main program starts here

addInstitution();

displayRates();

document.write('<BR><BR><BR><BR>');

response = window.prompt('Do you want to calculate the interest on an amount of money (Y/N)? ','');

while(response.toLowerCase() == 'y')
{
amountInPounds = window.prompt('Enter amount in Pounds ','');
interest = calculateInterest(amountInPounds);
document.write('£ '+ amountInPounds + ' attracts £' + interest + ' interest');
document.write('<BR><BR><BR>');
response = window.prompt('Do you want to calculate the interest for another amount (Y/N)? ','')
}

</script>
</head>
<body>
</body>
</html>

java_junkie

8:31 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



I want the program to prompt user for the name of the institution and the interest rates and store these values in the next free element of the appropriate arrays. And when the arrays are already full then an appropriate message to the user should be printed. And the program is already doing that, also the program should repeatedly asked whether they want to add a new institution ('A' or 'a'), print out the rates ('P' or 'p') or quit ('Q' or 'q') and which calls the appropriate function and if possible it should accept input in upper and lower case and if the user input an unrecognised input the the program should just continue to prompt for the next action.

That's all I need the program to do. Thanks for your time

java_junkie

8:34 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



it should be able to print out the current Account, Saving Account, and eSaving Account including their values.

java_junkie

8:44 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



Is it possible that the print out is properly arranged?

Bernard Marx

9:07 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



java_junkie, Sir. This is college homework (Open University?). You may find someone to write the entire script for you, but it's really not a good idea. You won't learn much, and it's likely that your tutor will be scanning forums like this for people looking for an easy way out.

It's fine asking for hints, tips, and pointers to where you have slipped up, but, when you come to hand in your work, you should supply links to any forum threads where you have asked questions about the project. So it's best to limit the scope of your questions in a way that your tutor would find acceptible.

This is basic stuff, so I'd recommend going back and starting again.

Follow the instructions carefully. For instance, the array, bankNamesArray, should be length 10, with the remaining positions filled with empty strings (acc. to instructions).

Take everything one step at a time. The first function in your brief, addInstitution, isn't anywhere near correct in your code, so there's no point in doing ay other functions yet.

java_junkie

9:20 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



ok