pro

pro

a company need a system to store the data about the employees , the number of employees is dynamic , you need to store the following attributes : name , age , salary and note that we need to solve it using array and class

View Answers

December 7, 2010 at 1:07 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
public class EmployeeData{
public static void main(String[] args) throws Exception{
    String name[]=new String[2];
    String age[]=new String[2];
    String salary[]=new String[2];
    String note[]=new String[2];
    Scanner input=new Scanner(System.in);
    for(int i=0;i<2;i++){
        System.out.println();
        System.out.println("Employe "+(i+1));
        System.out.print("Enter Name:  ");
        name[i]=input.nextLine();
        System.out.print("Enter Age:  ");
        age[i]=input.nextLine();
        System.out.print("Enter Salary:  ");
        salary[i]=input.nextLine();
        System.out.print("Enter Note:  ");
        note[i]=input.nextLine();
    }
    FileWriter fw=new FileWriter(new File("employee.txt"),true);
    BufferedWriter bw=new BufferedWriter(fw);
    for(int i=0;i<2;i++){
        bw.write(name[i]+" "+age[i]+" "+salary[i]+" "+note[i]);
        bw.newLine();
    }
    bw.close();
}
}

Thanks


December 7, 2010 at 1:07 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
public class EmployeeData{
public static void main(String[] args) throws Exception{
    String name[]=new String[2];
    String age[]=new String[2];
    String salary[]=new String[2];
    String note[]=new String[2];
    Scanner input=new Scanner(System.in);
    for(int i=0;i<2;i++){
        System.out.println();
        System.out.println("Employe "+(i+1));
        System.out.print("Enter Name:  ");
        name[i]=input.nextLine();
        System.out.print("Enter Age:  ");
        age[i]=input.nextLine();
        System.out.print("Enter Salary:  ");
        salary[i]=input.nextLine();
        System.out.print("Enter Note:  ");
        note[i]=input.nextLine();
    }
    FileWriter fw=new FileWriter(new File("employee.txt"),true);
    BufferedWriter bw=new BufferedWriter(fw);
    for(int i=0;i<2;i++){
        bw.write(name[i]+" "+age[i]+" "+salary[i]+" "+note[i]);
        bw.newLine();
    }
    bw.close();
}
}

Thanks









Related Tutorials/Questions & Answers:
pro
ModuleNotFoundError: No module named 'pro'
ModuleNotFoundError: No module named 'pro'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pro' How to remove the ModuleNotFoundError: No module named 'pro' error
Advertisements
Version of com.gocardless>gocardless-pro dependency
List of Version of com.gocardless>gocardless-pro dependency
Version of com.gocardless>gocardless-pro dependency
List of Version of com.gocardless>gocardless-pro dependency
Version of com.hynnet>jimi-pro dependency
List of Version of com.hynnet>jimi-pro dependency
ModuleNotFoundError: No module named 'desc-pro'
ModuleNotFoundError: No module named 'desc-pro'  Hi, My Python... 'desc-pro' How to remove the ModuleNotFoundError: No module named 'desc-pro... to install padas library. You can install desc-pro python with following
ModuleNotFoundError: No module named 'diacamma-pro'
ModuleNotFoundError: No module named 'diacamma-pro'  Hi, My Python... 'diacamma-pro' How to remove the ModuleNotFoundError: No module named 'diacamma-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'navi-Pro'
ModuleNotFoundError: No module named 'navi-Pro'  Hi, My Python... 'navi-Pro' How to remove the ModuleNotFoundError: No module named 'navi-Pro... to install padas library. You can install navi-Pro python with following
ModuleNotFoundError: No module named 'nester_pro'
ModuleNotFoundError: No module named 'nester_pro'  Hi, My Python... 'nester_pro' How to remove the ModuleNotFoundError: No module named 'nester_pro' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'print_pro'
ModuleNotFoundError: No module named 'print_pro'  Hi, My Python... 'print_pro' How to remove the ModuleNotFoundError: No module named 'print_pro' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'pro_clash'
ModuleNotFoundError: No module named 'pro_clash'  Hi, My Python... 'pro_clash' How to remove the ModuleNotFoundError: No module named 'pro... have to install padas library. You can install pro_clash python with following
ModuleNotFoundError: No module named 'pro-lambda'
ModuleNotFoundError: No module named 'pro-lambda'  Hi, My Python... 'pro-lambda' How to remove the ModuleNotFoundError: No module named 'pro... have to install padas library. You can install pro-lambda python
ModuleNotFoundError: No module named 'satang-pro'
ModuleNotFoundError: No module named 'satang-pro'  Hi, My Python... 'satang-pro' How to remove the ModuleNotFoundError: No module named 'satang-pro' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'scida-pro'
ModuleNotFoundError: No module named 'scida-pro'  Hi, My Python... 'scida-pro' How to remove the ModuleNotFoundError: No module named 'scida-pro' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'sphinxsharp-pro'
ModuleNotFoundError: No module named 'sphinxsharp-pro'  Hi, My... named 'sphinxsharp-pro' How to remove the ModuleNotFoundError: No module named 'sphinxsharp-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'textlocal-pro'
ModuleNotFoundError: No module named 'textlocal-pro'  Hi, My... 'textlocal-pro' How to remove the ModuleNotFoundError: No module named 'textlocal-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'textlocal-pro'
ModuleNotFoundError: No module named 'textlocal-pro'  Hi, My... 'textlocal-pro' How to remove the ModuleNotFoundError: No module named 'textlocal-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'xlwings-pro'
ModuleNotFoundError: No module named 'xlwings-pro'  Hi, My Python... 'xlwings-pro' How to remove the ModuleNotFoundError: No module named 'xlwings-pro' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'desc-pro'
ModuleNotFoundError: No module named 'desc-pro'  Hi, My Python... 'desc-pro' How to remove the ModuleNotFoundError: No module named 'desc-pro... to install padas library. You can install desc-pro python with following
ModuleNotFoundError: No module named 'diacamma-pro'
ModuleNotFoundError: No module named 'diacamma-pro'  Hi, My Python... 'diacamma-pro' How to remove the ModuleNotFoundError: No module named 'diacamma-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'face_pro'
ModuleNotFoundError: No module named 'face_pro'  Hi, My Python... 'face_pro' How to remove the ModuleNotFoundError: No module named 'face_pro... to install padas library. You can install face_pro python with following
ModuleNotFoundError: No module named 'gocardless-pro'
ModuleNotFoundError: No module named 'gocardless-pro'  Hi, My... named 'gocardless-pro' How to remove the ModuleNotFoundError: No module named 'gocardless-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'guestbook-pro'
ModuleNotFoundError: No module named 'guestbook-pro'  Hi, My... 'guestbook-pro' How to remove the ModuleNotFoundError: No module named 'guestbook-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jovian-pro'
ModuleNotFoundError: No module named 'jovian-pro'  Hi, My Python... 'jovian-pro' How to remove the ModuleNotFoundError: No module named 'jovian-pro' error? Thanks   Hi, In your python environment you
home button macbook pro keyboard
home button macbook pro keyboard  what is the substitute of Home and End button on macbook pro keyboard?   Home = Function Key (Fn) + Left Arrow End = Function Key (Fn) + Right Arrow
Microsoft Visual Fox Pro - SQL
Microsoft Visual Fox Pro  how can create a query using sql on microsoft visual fox pro 6.0
Final Cut Pro X
Final Cut Pro X The Final Cut Pro X is the name of new innovation in the video... during video editing. In fact, today Final Cut Pro X has created... introduces the many formerly missing in action section of its Final Cut Pro site
Version of com.datomic>client-impl-pro dependency
List of Version of com.datomic>client-impl-pro dependency
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'  Hi...: No module named 'coinmarketcap-pro-api' How to remove the ModuleNotFoundError: No module named 'coinmarketcap-pro-api' error? Thanks   Hi
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'  Hi...: No module named 'coinmarketcap-pro-api' How to remove the ModuleNotFoundError: No module named 'coinmarketcap-pro-api' error? Thanks   Hi
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'  Hi...: No module named 'coinmarketcap-pro-api' How to remove the ModuleNotFoundError: No module named 'coinmarketcap-pro-api' error? Thanks   Hi
ModuleNotFoundError: No module named 'pro-gan-pth'
ModuleNotFoundError: No module named 'pro-gan-pth'  Hi, My Python... 'pro-gan-pth' How to remove the ModuleNotFoundError: No module named 'pro-gan-pth' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'pro-gan-pytorch'
ModuleNotFoundError: No module named 'pro-gan-pytorch'  Hi, My... named 'pro-gan-pytorch' How to remove the ModuleNotFoundError: No module named 'pro-gan-pytorch' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pro-net-algorithm'
ModuleNotFoundError: No module named 'pro-net-algorithm'  Hi, My... named 'pro-net-algorithm' How to remove the ModuleNotFoundError: No module named 'pro-net-algorithm' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pro-net-dynamic-task'
ModuleNotFoundError: No module named 'pro-net-dynamic-task'  Hi...: No module named 'pro-net-dynamic-task' How to remove the ModuleNotFoundError: No module named 'pro-net-dynamic-task' error? Thanks   Hi
ModuleNotFoundError: No module named 'pro-net-registry'
ModuleNotFoundError: No module named 'pro-net-registry'  Hi, My... named 'pro-net-registry' How to remove the ModuleNotFoundError: No module named 'pro-net-registry' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pro-net-task'
ModuleNotFoundError: No module named 'pro-net-task'  Hi, My Python... 'pro-net-task' How to remove the ModuleNotFoundError: No module named 'pro-net-task' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pro-net-worker'
ModuleNotFoundError: No module named 'pro-net-worker'  Hi, My... named 'pro-net-worker' How to remove the ModuleNotFoundError: No module named 'pro-net-worker' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'recap-deepl-pro'
ModuleNotFoundError: No module named 'recap-deepl-pro'  Hi, My... named 'recap-deepl-pro' How to remove the ModuleNotFoundError: No module named 'recap-deepl-pro' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'satang-pro-signer-x'
ModuleNotFoundError: No module named 'satang-pro-signer-x'  Hi, My... named 'satang-pro-signer-x' How to remove the ModuleNotFoundError: No module named 'satang-pro-signer-x' error? Thanks   Hi
ModuleNotFoundError: No module named 'scrapy-random-useragent-pro'
ModuleNotFoundError: No module named 'scrapy-random-useragent-pro'  ...: No module named 'scrapy-random-useragent-pro' How to remove the ModuleNotFoundError: No module named 'scrapy-random-useragent-pro' error? Thanks
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'
ModuleNotFoundError: No module named 'coinmarketcap-pro-api'  Hi...: No module named 'coinmarketcap-pro-api' How to remove the ModuleNotFoundError: No module named 'coinmarketcap-pro-api' error? Thanks   Hi
ModuleNotFoundError: No module named 'font-source-sans-pro'
ModuleNotFoundError: No module named 'font-source-sans-pro'  Hi...: No module named 'font-source-sans-pro' How to remove the ModuleNotFoundError: No module named 'font-source-sans-pro' error? Thanks   Hi
ModuleNotFoundError: No module named 'font-source-serif-pro'
ModuleNotFoundError: No module named 'font-source-serif-pro'  Hi...: No module named 'font-source-serif-pro' How to remove the ModuleNotFoundError: No module named 'font-source-serif-pro' error? Thanks   Hi
WindowTester Pro
WindowTester Pro       Experience ultimate testing flexibility WindowTester Pro offers cutting-edge technology for testing Swing and SWT Java graphical user
Maven Dependency gocardless-pro >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.gocardless >> gocardless-pro version0.0.1 in your project
Maven Dependency gocardless-pro >> 0.0.2
You should include the dependency code given in this page to add Maven Dependency of com.gocardless >> gocardless-pro version0.0.2 in your project
Maven Dependency gocardless-pro >> 0.0.3
You should include the dependency code given in this page to add Maven Dependency of com.gocardless >> gocardless-pro version0.0.3 in your project
Maven Dependency gocardless-pro >> 0.1.0
You should include the dependency code given in this page to add Maven Dependency of com.gocardless >> gocardless-pro version0.1.0 in your project
Maven Dependency gocardless-pro >> 0.2.0
You should include the dependency code given in this page to add Maven Dependency of com.gocardless >> gocardless-pro version0.2.0 in your project

Ads