My question is quite simple I would like to create an array and populate it with some string items. Below is a simple code containing two classes and one main method (pretty basic program).
public class CompanyDetails {
public static void main (String[] args){
CompanyInput apple = new CoInput();
apple.coDetailsSummary("Apple","USA", "NA");
apple.computeNoOfJoinees();
CompanyInput htc = new CoInput();
htc.coDetailsSummary("HTC", "Thailand", "NA");
htc.computeNoOfJoinees();
}
}
public class CompanyInput {
float noOfJoinees;
String companyName;
String address;
String phoneNumber;
int randomInt,randomInt1;
int noOfEmployees;
Array gh;
void coDetailsSummary(String companyName, String address, String phoneNumber) {
// TODO Auto-generated method stub
System.out.println("Company Name : "+companyName);
System.out.println("Address : "+address);
System.out.println("Contact Information : "+phoneNumber);
}
void computeNoOfJoinees(){
float m1,m2, m3;
Random randomGenerator = new Random();
for (int idx = 1; idx <= 10; ++idx)
randomInt = randomGenerator.nextInt(30);
randomInt1 = randomGenerator.nextInt(20);
m1 = randomInt;
m2 = randomInt1;
m3 = m1+m2/100;
System.out.print("The number of joinees joining every month : "+m3);
System.out.println("\n");
}
}
I would like to create an array with name as the "companyName" and populate it with all the values that will be given as output.
For e.g
Company Name : Apple
Address : USA
Contact Information : NA
The number of joinees joining every month : 13.0
All of these values must be inserted into an array automatically when I run the program. The result should look like this
Apple[] = {Apple,USA,NA,13.0}
how can I achieve this ?