Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Array Values to Global Varibles
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ron
Java Array Values to Global Varibles
1 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners



Advertisement
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
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 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
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
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
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
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: General Format
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
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... to all global variables, the variable names are the keys of the array. Code
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
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.... Different types of array used in Java are One-dimensional, Two-dimensional and multi... of an Array Initialization of an Array Arrays in Java for different data
Java Array Length
Java Array Length       In this section, you will learn about the java array length. The java array... about array click on: http:/www.roseindia.net/java/language/introduction-to-java
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>
Java array
Java array   How can one prove that the array is not null but empty
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
unable to find resource 'VM_global_library.vm' - Java Server Faces Questions
unable to find resource 'VM_global_library.vm'  pls help me, I am... template : VM_global_library.vm Tue Aug 12 12:03:54 CAT 2008 [error] ResourceManager : unable to find resource 'VM_global_library.vm' in any resource loader. Tue
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
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
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
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
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
Advertisements
 

 

 

DMCA.com