0

i have written a simple object array which takes five strings. what i am trying to do is is use a for loop to create to entries in the object array at position 0 and 1. Then create a folder which holds a text file for position 0 and the create a folder which holds a text file for position 1. The expected result

folder0-> 0.txt

text file content

Jeremey 12 male 120 120

Somebody 12 female 100 100

folder1-> 1.txt

text file content

Jeremey 12 male 120 120

Somebody 12 female 100 100

the following is sample of code already written.

object array class:

public class Info
{
    private String Name;
    private String age;
    private String Gender;
    private String Height;
    private String weight;

    Info(String Name, String age, String Gender, String Height, String weight)
    {
        this.Name = Name;
        this.age = age;
        this.Gender = Gender;
        this.Height = Height;
        this.weight = weight;
    }


    public String getName()
    {
        return this.Name;
    }

    public String getAge()
    {
        return this.age;
    }

    public String getGender()
    {
        return this.Gender;
    }

    public String getHeight()
    {
        return this.Height;
    }

    public String getWeight()
    {
        return this.weight;
    }



}

Main class:

import java.util.*;

public class UseInfo
{
    public static void main(String [] args)
    {

        Scanner in = new Scanner(System.in);

        Info infor[] = new Info[2];

        for(int i = 0; i < 2; i++)
        {
        System.out.println("Please enter Name: ");
        String name = in.nextLine();

        System.out.println("Please enter age: ");
        String age = in.nextLine();

        System.out.println("Please enter Gender: ");
        String gender = in.nextLine();

        System.out.println("Please enter Height: ");
        String height = in.nextLine();

        System.out.println("Please enter Weight: ");
        String weight = in.nextLine();


        infor[i] = new Info(name, age, gender, height, weight);

        }


        for(int k = 0; k < infor.length; k++)
        {
            System.out.println("Name : " + infor[k].getName() + " Age : " + infor[k].getAge() + " Gender : " + infor[k].getGender() + " Height : " + infor[k].getHeight() + " Weight : " + infor[k].getWeight() );

        }

    }

}

I cant figure out how to take the information from the array and pass it in to a file and store file in folder.

  • can u alteast reference the duplicate – Jeremey Samaroo Aug 16 '17 at 00:20
  • what do you mean? – Scary Wombat Aug 16 '17 at 00:22
  • u said its a duplicate however you did not say what it was a duplicate of – Jeremey Samaroo Aug 16 '17 at 00:49
  • At the top of the question, it says **This question already has an answer here:** - can you see that? – Scary Wombat Aug 16 '17 at 00:50
  • yes i saw that i even followed the thread and while it is a proposed solution it is not the solution i am looking for. Thus your reference to duplication implies that by following another thread or the original thread of an idea that because to ideas seem similar that they are one in the same. An i am saying if that is what you are saying it is illogical stand as evolution and languages and ideas would naturally provide out of the box solutions over time. So by your logic one solution always works and any question that is similar is a duplicate. – Jeremey Samaroo Aug 16 '17 at 10:21
  • You have not provided any code and in your above comment you do not say why the link does not fulfill your requirements. I (and other members of SO) am very happy to help you, but we need your input first. Just because a question has been closed does not mean that it can not be re-opened, so give us some input. – Scary Wombat Aug 17 '17 at 00:13

0 Answers0