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



Home Answers Viewqa Java-Beginners core java programming question

Have Programming Question? Ask it here!
 
 
 


suneetha
core java programming question
1 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


How to write a java program to list the customer names arrived to a restuarant on a particular date in alphabetical order with arguments as 1 filename yymmdd cust


Advertisement
View Answers

December 17, 2010 at 11:52 AM


Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
class ResApplication  
{
    public static void main(String[] args) throws Exception
    {
        File f=new File("C:/Customer.txt");
        BufferedWriter bw=new BufferedWriter(new FileWriter(f,true));
        Scanner input=new Scanner(System.in);
        for(int i=1;i<=10;i++){
        System.out.print("Enter Customer Name: ");
        String name=input.nextLine();
        System.out.print("Enter Date(yyyy-mm-dd): ");
        String date=input.nextLine();
        bw.write(name+" "+date);
        bw.newLine();
        }
        bw.close();

        System.out.println();
        System.out.print("Enter date to view the list of customers(yyyy-mm-dd): ");
        String d=input.nextLine();
        BufferedReader br=new BufferedReader(new FileReader(f));
        String line="";
        ArrayList list = new ArrayList();
        ArrayList cusList=new ArrayList();
           while ((line = br.readLine()) != null) {
           list.add(line);
            }
           Iterator itr;
           for (itr = list.iterator(); itr.hasNext();) {
           String str = itr.next().toString();
           String[] splitSt = str.split(" ");
           String name = "", date = "";
           for (int i = 0; i < splitSt.length; i++) {
           name = splitSt[0];
           date = splitSt[1];
           if(date.equals(d)){
           cusList.add(name);
           }
           }
           }
           Set set = new HashSet(cusList);
    ArrayList l=new ArrayList(set);
    Collections.sort(l);
    for(int i=0;i<l.size();i++){
    System.out.println(l.get(i).toString());
    }
}
}

Thanks



Related Tutorials/Questions & Answers:
core java programming question
core java programming question  How to write a java program to list the customer names arrived to a restuarant on a particular date in alphabetical order with arguments as 1 filename yymmdd cust   Hi Friend, Try
core Java programming
core Java programming  Hi, Thanks for ur previous answers.... I need some of these answers also... Bharathi Indian Cuisine is a leading Indian...;TIME:HHMMSS;ITEM1:QTY:PRICE;ITEM2:PRICE2;] They are looking for a Java Program
Advertisements
Core Java Interview Question, Interview Question
Core Java Interview Question   ....   Core Java Interview Question Page 1 How could Java... to a file?      Core Java Interview Question Page 2
Core Java Programming - Java Beginners
Core Java Programming  Write a program in Java which initializes the starting date as your birthday and displays the date 90 days later in the format day name, month name, day, year   Hi friend, Code to solve
Core Java Programming - Java Beginners
Core Java Programming  Write a program in Java which generates a random number between 0 and 1. If the number generated is less than 0.5 then the program must print ?The Value is less than 0.5? and if the number generated
Core Java Interview Question, Interview Question
Core Java Interview Question Page 24       Question: Why do we need public static void main.... Question: What is reflection in java Answer: Reflection allows Java code
Java Programming Question
Java Programming Question  write a program in java to show thread working with sleep and wait method   Hi Friend, Please visit the following links: Wait Method Sleep Method Thanks
core java question - Java Interview Questions
core java question  I Have been asked the question in interview why we use constructors????? or what is the need of constructors?? or what is the utility of constructors????  to intialize the instance variabe we
Core Java Interview Question, Interview Question
Core Java Interview Question Page 9       Question: What are the uses of Serialization... computer using such client/server Java technologies as RMI or socket programming
Core Java Interview Question, Interview Question
Core Java Interview Question Page 29       Flow Control and exception Question: What... at the end of the body Question: When do you use continue and when do you use
Core Java Interview Question, Interview Question
Core Java Interview Question Page 14       Question: What is clipping? Answer: Clipping... that is implemented in a language other than Java. Question: Can a for statement loop
Core Java Interview Question, Interview Question
Core Java Interview Question Page 32   ... Question: What is the ultimate ancestor of all java classes Answer: Object class is the ancestor of all the java classes Question: What
Core Java Interview Question, Interview Question
Core Java Interview Question Page 5   ... Java technologies as RMI or socket programming. To "flatten"... enterprise java beans. To send objects between the servers in a cluster. Question
Core Java Interview Question, Interview Question
Core Java Interview Question Page 21       Question: How are the elements of a GridLayout... and are laid out using the squares of a grid. Question: What an I/O filter? Answer: An I
programming question - Java Magazine
programming question  I have an SGVT map displaying on a phone emulator but then want to search for a given location on the map and display... tool. I need a java solution to this please
Core Java Interview Question, Interview Question
Core Java Interview Question Page 17       Question: What is the difference between... application window that can have a menu bar. Question: Which class is extended by all
Java Programming Question
Java Programming Question  Write a program in Java to accept 10 different numbers an store it in text file.   Hi Friend, Try this: import java.io.*; import java.util.*; class AcceptNumbers{ public static void main
Core Java Interview Question, Interview Question
Core Java Interview Question Page 22       Question: What is a compilation unit? Answer: A compilation unit is a Java source code file. Question: What interface
Core Java Interview Question, Interview Question
Core Java Interview Question Page 23       Question: To what value is a variable... and interfaces that are loaded by a Java program. Question: How does a try statement
Java Programming Question
Java Programming Question  Write a program in Java to create a menu bar with the help of event handlers.   Hi Friend, Try this: import javax.swing.*; import java.awt.event.*; public class SwingMenuBar{ public
Core Java Interview Question, Interview Question
Core Java Interview Question Page 27       Modifiers Question: What are access modifiers... written in non java language Question: What are transient variables
Core Java Interview Question, Interview Question
Core Java Interview Question Page 18       Question: Is &&= a valid Java operator? Answer: No, it is not. Question: Name the eight primitive Java
Core Java Interview Question, Interview Question
Core Java Interview Question Page 2   .... Question: What comes to mind when you hear about a young generation in Java... mentions a shallow copy in Java? Answer: Object cloning. Question: If you're
Core Java Interview Question, Interview Question
Core Java Interview Question Page 26       Language Fundamentals Question: How... 64 - - Question: What types
Core Java Interview Question, Interview Question
Core Java Interview Question Page 16  ... implementation is deferred to a subclass. Question: How are Java source code files... and interfaces. Source code files use the .java extension. Question: What
Core Java Interview Question, Interview Question
Core Java Interview Question Page 12       Question: What is a transient variable? Answer... collections of objects. Question: How does Java handle integer overflows
Core Java Interview Question, Interview Question
Core Java Interview Question Page 15  ... is to provide access to the Java runtime system. Question: How many times may... takes an argument of the String[] type. Question: Which Java operator is right
Java Programming Question
Java Programming Question  Write a program in Java to create student information form an submit detail in database.   Hi Friend, Try this: import java.awt.*; import java.sql.*; import javax.swing.*; import
Core Java Interview Question, Interview Question
Core Java Interview Question Page 13       Question: What is an Iterator interface? Answer.... Question: What is the difference between the >> and >>> operators
Core Java Interview Question, Interview Question
Core Java Interview Question Page 30       Objects and Classes Question: What's... while regular methods could be called many times. Question: What
Core Java Interview Question, Interview Question
Core Java Interview Question Page 19       Question: What is the difference between static... variables take on unique values with each object instance. Question: What
Core java interview question, object creation.
Core java interview question, object creation.  How can we restrict to create objects for more than five? That means i want only 5 objects, how to restrict to create 6th objects
Core Java Interview Question, Interview Question
Core Java Interview Question Page 20       Question: Name four Container classes. Answer: Window, Frame, Dialog, File Dialog, Panel, Applet, or ScrollPane Question: What
programming question - Java Beginners
programming question  Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion Picture Association of America (MPAA) rating (eg., Rated G, PG-13, R), ID Number
Core Java Interview Question, Interview Question
Core Java Interview Question Page 25  ... be called. Question: Does java support virtual functions Answer: No java... Question: What is JVM Answer: When we install a java package
Core Java Interview Question, Interview Question
Core Java Interview Question Page 11       Question: What is serialization ?  Answer: Serialization is the process of writing complete state of java object
Core Java Interview Question, Interview Question
Core Java Interview Question Page 4   ... of the class object: Java- class-name.field-or-method-name Question: What.... Java Code private static final int MAXATTEMPTS = 10; Question
Core Java Interview Question, Interview Question
Core Java Interview Question Page 31       Threads Question: Where does java thread... (Most of the support resides here) The java.lang.Object class The java
Core Java Interview Question, Interview Question
Core Java Interview Question Page 28       Conversion Casting and Promotion Question: What... primitive types to be accessed as objects. Question: What are the four general
Core Java Interview Question, Interview Question
Core Java Interview Question Page 7       Question: What... of java object into output stream, that stream can be file or byte array or stream
Core Java Interview Question, Interview Question
Core Java Interview Question Page 10       Question: What is the difference between notify... by a call to notify (so it is often better to use notifyAll than notify). Question
Core Java Interview Question, Interview Question
Core Java Interview Question Page 6       Question: How can i tell what state a thread...++){ System.out.println(ts[i]); } } } Question: What methods java providing
Java programming question - Java Beginners
Java programming question   Give the definition of a class named Doctor whose objects are records for a clinic's doctors. This class will be derived class of the class SalariedEmployee that is given below the question. A Doctor
Java programming question - Java Beginners
Java programming question  I want to write a program that converts temperatures from celsius to fahrenheit and vice versa. It also converts kilometers to miles and vice versa using "methods".  Hi Friend, Try
core question
core question  can we override or overload static methods   Hi Friend, We can overload static methods but we cannot override static methods. Thanks
core java
core java  basic java interview question
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
socket programming question
socket programming question   can you respond to me the multiple clients chat application java code and a server that manages the clients using the socket programming in java
core java
core java  how to display characters stored in array in core java
 

 

 

DMCA.com