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



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

Have Programming Question? Ask it here!
 
 
 


Ron
Java Array Values to Global Varibles
1 Answer(s)      5 years and 9 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
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
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
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
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
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
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
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
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
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
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
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
C Array default values
C Array default values     ... of the array is 4. We have allocated only two values in the array like this:  ...;the last values in the array to the default value. When the code is run, the pre
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
jagged array in java
jagged array in java   jagged array in java with example
Array declaration in Java
Array in Java can be used to store similar kind of data or element... an array in Java: One dimensional array can be declared as: int OneDArray[]; or int...]; Here array can store up to 10 values of type int. Initializing and Instantiating
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
In this section, you will learn about array in Java
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
form values in java script - Struts
form values in java script  how to get form values in java script functions with struts1.1
char array java
char array java  char array programmes in java All capital letters should be replaced with the next letter
global variable in objective c
global variable in objective c  Declaring global variable in objective c
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 - Java Beginners
Array  how to declare array of hindi characters in java
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
Java array - Java Beginners
Java array  Q 1- write a program that counts the frequency... to convert a binary no to integer with out using in built functions? Q 3- Write a program tofind sum of all non dioganal elements of a two dimensional NxN array
Array sorting - Java Beginners
and the velue is name array), and sort the hasp map on the basis of there values ie name...Array sorting   Hello All. I need to sort one array based on the arrangement of another array. I fetch two arrays from somewhere
java array problem
java array problem  suppose i have an array a[] at a[0] i have value 5,7 the thing is that i want to assign the value of array a[0]=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
 

 

 

DMCA.com