Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: I cannot get to print out all my information.

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I cannot get to print out all my information.

    I have written this code but i am having trouble printing out all the information at the end. Should I use ToString? Any help would be appreciated.

    package drycleaner;
     
    import java.util.Scanner;
     
    /**
     *
     * @author Kl2eativ
     */
    public class DryCleaning {
        public static void main(String[] args) 
            {
            Scanner s = new Scanner(System.in);
            System.out.println("For how many stores do you want to enter information for? ");
            int storeNum = s.nextInt();
            String[] dryCleaningStores = new String[storeNum];
            s.nextLine();
            for (int i = 0; i < storeNum; i++)
                {
                    System.out.println("Please enter the store name: ");
                    String st = s.nextLine();
                    System.out.println("Enter total sales: ");
                    double ts = s.nextDouble();
                    System.out.println("Enter total of machines broken: ");
                    int mb = s.nextInt();
                    System.out.println("Number of employees: ");
                    int emp = s.nextInt();
                    s.nextLine();
                }
     
     
        }
     
    }


  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default Re: I cannot get to print out all my information.

    Quote Originally Posted by kl2eativ View Post
    I have written this code but i am having trouble printing out all the information at the end.
    First of all, what are you having trouble with? You seem to be using println statements correctly. Can you please be more specific about what you are trying to print out?
    Last edited by dpek; January 24th, 2011 at 09:39 PM.

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I cannot get to print out all my information.

    Sorry if I did not make myself clear, When I ask for how many stores does the user wants to enter info for, Lets say he puts in 3, after the info for all 3 have been inputted, i want to print the info for all 3. Like say, This is the information for all 3 stores.

  4. #4
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Wink Re: I cannot get to print out all my information.

    Why don't you use ArrayList then?

    Have a method, something which would get called for every store information. Once you receive your parameters, pass them along to it and store them in ArrayList.
    Your method should look like,
    public void add(String a, double b, int c, int d)
    Refer how to add to ArrayList here: ArrayList add

    Then once you are done with 3 inputs, iterate over the Arraylist and display all the info stored. As ArrayList adds the data sequentially, you would get the things in the same order as you have added them.

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!

    Sun: Java Coding Conventions

    Click on THANKS if you like the solution provided.
    Click on Star if you are really impressed with the solution.

  5. #5
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I cannot get to print out all my information.

    I thought about that but I have to use an array

Similar Threads

  1. taking information from one array into another
    By Stn in forum Object Oriented Programming
    Replies: 1
    Last Post: January 18th, 2011, 11:56 AM
  2. can't get all the information out of my array at once... please help
    By Tate in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 28th, 2010, 06:22 AM
  3. [SOLVED] Class not passing information
    By DiPep in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 26th, 2010, 11:04 AM
  4. Some information on retrieving packets
    By Cheetah in forum Java Networking
    Replies: 0
    Last Post: July 11th, 2010, 09:43 PM
  5. Getting information from a folder
    By shadihrr in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: February 23rd, 2010, 04:13 PM