Java Array Values to Global Varibles

Java Array Values to Global Varibles

View Answers

August 4, 2008 at 4:42 PM

Hi..Ron..

I am sending you the following code..which is passing that global variables value into the method "mortgageSelect()" and thus you will take these value into your method "rates" and "periods" variable ..This will solve your problem....Full code is as given below...If still your problem is unsolved then please send full detail regarding your problem so that I can better understand your problem.. Try this code...
ThankYou...

Code is :
import java.io.*;
public class GlobalArray {

GlobalArray(){}

public void mortgageSelect(double rate,int period) throws IOException{

double rates=rate;
int periods=period;
double mRate [] = {5.35, 5.5, 5.75};
int mTerm [] = {7, 15, 30};
int choice;
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));

/* selection 1 = 7 year loan
* selection 2 = 15 year loan
* selection 3 = 30 year loan
*/

System.out.print("Loan Options\n");
System.out.print("1. 7 Year Loan at 5.35% Interest\n");
System.out.print("2. 15 Year Loan at 5.5% Interest\n");
System.out.print("3. 30 Year Loan at 5.75% Interest\n");
System.out.print("\nPlease select from the loan options listed above: ");

choice = Integer.parseInt(dataIn.readLine());

if (choice >= 1 && choice < 4)
{
switch (choice)
{

case 1:
System.out.print("You have opted for a 7 year loan\n");
rates = mRate[0];
periods = mTerm[0];
System.out.printf("The interest rate of%6.2f %6.2f percent will be applied for a period of%2d %2d years", rate, mRate[0], periods, mTerm[0]);
break;
case 2:
System.out.print("You have opted for a 15 year loan\n");
rates = mRate[1];
periods = mTerm[1];
System.out.printf("The interest rate of%6.2f percent will be applied for a period of%2d years", mRate[1], mTerm[1]);
break;

case 3:
System.out.print("You have opted for a 30 year loan\n");
rates = mRate[2];
periods = mTerm[2];
System.out.printf("The interest rate of%6.2f percent will be applied for a period of%2d years", mRate[2], mTerm[2]);
break;
}
}
else
{
System.out.printf("The option you selected is not valid\n");// need to make sure when this displays the payment history is not displayed
}
}
public static void main(String args[]) throws IOException{

double rate=0.0;
int period=0;
GlobalArray ga= new GlobalArray();
ga.mortgageSelect(rate,period);
}
}









Related Tutorials/Questions & Answers:
Java Array Values to Global Varibles - Java Beginners
Java Array Values to Global Varibles  I am working on a program that provides users with 3 loan options. If global variables rate and periods... the value of certain mTerm[] and mRate[] arrays, I am unable to get those values
are my declared varibles right - Java Beginners
are my declared varibles right  here is what i have so far juswt wondering if my varibles are correct. public class Bug { public Bug(int... information on java visit to : http://www.roseindia.net/java/ Thanks
Advertisements
sorting an array of string with duplicate values - Java Beginners
sorting an array of string  Example to sort array string
sorting an array of string with duplicate values - Java Beginners
sorting an array of string with duplicate values  I have a sort method which sorts an array of strings. But if there are duplicates in the array it would not sort properly
sorting an array of string with duplicate values - Java Beginners
string with duplicate values  How to check the string with duplicate values
how to store array values into two different tables in java?
how to store array values into two different tables in java?  I have use 4/5 textboxes with same name(e.g.text1) and I get the values in a array and now I want to store these values in two different tables(i.e store 2 array
sorting an array of string with duplicate values - Java Beginners
String of Array  What is mean by string of array? And how one can add, delete the records from database in string format
how to Insert Array Values Into Separate Rows using java?
how to Insert Array Values Into Separate Rows using java?  how to Insert Array Values Into Separate Rows using java?  class...) { String array[][]={{"1","Angel","Delhi"},{"2","John","Chennai"},{"3","William
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java? ... count is 4. array should loop 4 locateids. this i should write it in java... need to store this in array by loop through it. So that, I should able
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java? ... count is 4. array should loop 4 locate_ids. this i should write it in java... need to store this in array by loop through it. So that, I should able
PHP Array Count Values
of values, i.e. total number of appearance of an element, in an array. PHP provides array_count_values() function to count the number of variables.  General description of array_count_values() is given below:ADS_TO_REPLACE_1
Storing the Color Image pixel values into 2d array
Storing the Color Image pixel values into 2d array  i want to store the color image pixel values into 2d array and agiain the array have to store into a text file using java... plz provide the code
Get values from session to array
Get values from session to array  Hello I have stored my 2 dimensional array into session using C#.net. Now on aspx page i want to store same session variable into 2 dimensional array. And how to find count of session valaiable
Get values from session to array
Get values from session to array  Hello I have stored my 2 dimensional array into session using C#.net. Now on aspx page i want to store same session variable into 2 dimensional array. And how to find count of session valaiable
how i can creat string array, with global visibility.
how i can creat string array, with global visibility.  Problem : Write a Java class having a String array, with global visibility. Add a method that adds a given sting to the string array. Add a method that searches
how i can creat string array, with global visibility.
how i can creat string array, with global visibility.  Problem : Write a Java class having a String array, with global visibility. Add a method that adds a given sting to the string array. Add a method that searches
JavaScript Array Values
JavaScript Array Values       The Tutorial describes you a Array Values code in JavaScript. The Program create a HTML page specifying a button name 'Display Array Values
Array in Java
An Array is the static memory allocation that holds a fixed number of values..._TO_REPLACE_1 Different types of array used in Java are One-dimensional, Two... of an Array Arrays in Java for different data types can be declared as follows
Use varibles from another class
Use varibles from another class  **I have two classes. class 1:** public class askfigures extends JFrame { method from class1: public void... = Integer.parseInt(n1); System.out.println("dsf") this.dispose(); Askvalues values
Java Array Length
Java Array Length       In this section, you will learn about the java array length. The java array enables the user to store values of the same type in contiguous memory allocations
Changing the value of Array in Java
Changing the Value of Array in Java   .... In this tutorial you will learn how to change array values. The one dimensional array program is provided Java application program about the explanation
Use of Array in Java
Use of Array in Java      ... object which can hold a values of same type. The length of an array is created...];. It will create an array of type int which can store 5 integer values. The next way
PHP Global Variable
PHP  Global Variable To access global variable in PHP we need to use global keyword or $GLOBALS associative array global is a keyword which helps us... of the array. Code for PHP Global Variable: <?phpADS_TO_REPLACE_2 $a=1
java array
java array  write a java method that takes an array of float values...)){ System.out.println("There are duplicate elements."); Float array...++){ array[i]=new Float(arr[i]); } Set<Float>
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array... sample code for how to retrive array values from html to jsp.   hi friend
What is Array in Java?
What is Array in Java?  Hi, What is Array in Java? How to create an array in Java and use it? Thanks   Hi, Array is very important in Java as it is used heavily in programming. Array is Java is a container object
Java array
Java array   How can one prove that the array is not null but empty
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
C Array default values
C Array default values     ... of the array is 4. We have allocated only two values in the array like this:ADS... that sets the last values in the array to the default value. When the code
shifting values - Java Beginners
shifting values  write a program to shift the array values in a circular way according to user's choice. user will supply the size of the array,array elements,the number of times the array will be shifted and also the direction
Java Array
Java Array   a) Write an array program that perform the following: i) Declares a String array initialized with the following strings: ââ?¬Å...?¬Â?. ii) Write a loop that displays the contents of each element in the array
Array declaration in Java
Array in Java can be used to store similar kind of data or element... Multidimensional Declaring an array in Java: One dimensional array can... store up to 10 values of type int. Initializing and Instantiating an Array: int
java array
java array  q4.array Write a program that accepts two arrays, an array of fruit names and an array of price of fruits, and a fruit name and returns the price of the fruit. (Assume that a price in the second array corresponds
Facing Problem to insert Multiple Array values in database - JSP-Servlet
Facing Problem to insert Multiple Array values in database  Hai friend , Iam beginner in jsp and creating the project in shopping cart but ihave facing the problem while inserting the data in database. iam using the MsAccess
values in combobox - Java Beginners
values in combobox  how to fill values in combo box i.e. select tag...: ComboBox var arr = new Array(); arr[0] = new Array("-select-"); arr[1] = new Array("Nokia","Sony","Motorola","Samsung"); arr[2] = new Array("Titan","HMT
java program based on array
java program based on array  write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask the use another nomber and pass the array and the no. entered to function called
java array
java array Two cells is a matrix will be called connected if they are adjacent...], a[3,2], a[3,3] } elements with weight 6 Problem: Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island
jagged array in java
jagged array in java   jagged array in java with example
How to calculate average of array in Java?
How to calculate average of array in Java?  Hi, I have an integer array and I want to calculate the average of the values in it. How to calculate average of array in Java? Thanks   Hi, You can iterate through
Array to Collection
ArraysToCollection The values into Array Java Struts JSP J2EE... Array to Collection       In this example we are converting values of an array into collection
Array in java
Array in java In following example we will discuss about Array in Java. Array... in memory at fixed size. We can use multiple type array. It can be used in Java, C..., Boolean, String object. We can store only primitive data in array. We have
Array in Java
Array in Java  public class tn { public class State{ String s_name; int p1; int p2; } public void f(){ State[] s = new State[10]; int [] i = new int[10]; i[0] = 1
Java plateform dependent values
Java plateform dependent values  How will you get the platform dependent values like line separator, path separator, etc., ?  we will get the the platform dependent values like line separator, path separator
Java Array
In this section, you will learn about array in Java
Selection Sort in Java
Selection sort in Java is used to sort the unsorted values in an array...;); System.out.println(); selection_srt(array, array.length); System.out.print("Values...: C:\array\sorting>javac selectionSort.java C:\array\sorting>java
Matrix Example in Java
; In Java tutorial, you will learn about array and matrix. An array... then, the array of int can only store the int values. It can't store other than... the for loop to print all the values stored in the array. At last use the main
char array java
char array java  char array programmes in java All capital letters should be replaced with the next letter
sorting array in java
sorting array in java  How to sort array in Java or JavaScript?   JavaScript Sorting array tutorial   Java Sort array of strings...[] args) { String array[]=new String[5]; Scanner input = new Scanner
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats values in reverse order . for example, the call of mirror function would transform
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats values in reverse order . for example, the call of mirror function would transform

Ads