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




Have Programming Question? Ask it here!
 
 
 


dodo zayat
pro
2 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


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


Advertisement
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
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
Advertisements
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
Microsoft Visual Fox Pro - SQL
Microsoft Visual Fox Pro  how can create a query using sql on microsoft visual fox pro 6.0
WindowTester Pro
WindowTester Pro       Experience ultimate testing flexibility WindowTester Pro offers cutting-edge technology for testing Swing and SWT Java graphical user
Re-installing Mac OS X on Mac Book Pro by formatting the Hard Disk
and then reinstalling the Mac OS X on your Mac Book Pro. Sometimes you need to reinstallMac OS X on your Mac Book pro due to certain reasons and often it looks a tedious task but it is actually not so. You can reinstall your Mac Book pro
GNATbench
GNATbench       GNATbench for Wind River Workbench brings the advantages of AdaCore?s GNAT Pro toolset to Wind River?s Workbench integrated development environment
XMLBuddy
. Now in two models: XMLBuddy and XMLBuddy Pro. Key features of XMLBuddy Pro
Clear Data Builder
Clear Data Builder        Clear Data Builder Plugin automates Flex-Java development with Flex Data Services: whether you are a Java Pro or have never coded in Java before
hi
hi   'print("code sample");`class example(){ public.static.void.main(); system.out.println("this is first pro");}   class example{ public static void main(String[]args){ System.out.println("this is first pro
Java - Java3D
Java  , Java Windows XP pro 64-bit Prompt please what install Java on computer with system Windows XP pro 64-bit
javascipt - Java Beginners
"; var pro_desc = document.createElement('input'); pro_desc.type="text"; pro_desc.id="pro_desc"; pro_desc.size=22
registration key - Java Beginners
registration key  I want the serial key for JCreator Pro 4.50. I lost it. If any body has it please send
javascript - Java Beginners
pro_desc = document.createElement('input'); pro_desc.type="text"; pro_desc.id="pro_desc"; pro_desc.size=13; pro
javascript - Java Beginners
"; var pro_desc = document.createElement('input'); pro_desc.type="text"; pro_desc.id="pro_desc"; pro_desc.size=22
programming of foxpro
programming of foxpro  hello sir , sir i am use the foxpro . but i know about c . sir how can i learn fox pro . i know about something about foxpro
PaintShopProTutorials
Paint Shop Pro Tutorials   ... NNTP forums for Paint Shop Pro, Photo Album and Studio are now available... Shop Pro Tutorial The only thing better than getting new software
conncetion with oracle throuth jdbc - JDBC
conncetion with oracle throuth jdbc  i use jdk1.5 when i compile our JDBC java pro. with ojdbc14.jar file it give no error. but when i run that class it give error of unsupported class version. which jar file use for compile
Get Java Version
array variable name 'pro' is initialized with respective value. 1.... for loop is used to display the name of Java version present in String pro using System.out.println. 2)properties.getproperties(pro[i])-This method return you
Andrew Stone Designs Twitter Applications
developed by Stone Designs called Twittlelator Pro. The Andrew Stone developed... The Twittelator Pro for iphone has the following features: Copy and Paste support
struts2
struts2  how to read properties file in jsp of struts2   Hi, You can use the Properties class of Java in your action class. Properties pro = new Properties(); FileInputStream in = new FileInputStream(f); pro.load
program and Interface builder
more custom them you will use UI elements pro grammatically and if you are making
Problem with Link To website with my Java Appliaction - Java Beginners
*; public class menu5 extends JFrame //implements ActionListener { //coursefrm pro... actionPerformed(ActionEvent ae){ coursefrm pro=new coursefrm(); pro.dis...); } public static void main(String z[]){ menu5 pro=new menu5(); pro.dis
How to open an Acroform in iText?
How to open an Acroform in iText?  I modified a client's Acroform in Acrobat Pro 9, and now the client says he can't open it in iText. I had never even heard of iText before this. It's been a while since I did any Java coding
How to find the exact PHP template I need?
How to find the exact PHP template I need?  Hi! I'm a PHP Pro?I think I am one?, but this is the first time for me to try a PHP template, so I have no clue on how to choose one. Do you have some tips to help me choose
Java - Development process
to integrate two java program. u can integrate java pro with other software or tool
GWT Designer
WindowBuilder Pro? and leverages its sophisticated development facilities
How to Upload Site Online
and office. Since 1999, CuteFTP Pro and CuteFTP Mac Pro have also been available alongside CuteFTP Home with free trial periods. WS_FTP Pro is a Windows-based program
Paint.NET
editing software packages such as Adobe Photoshop, Corel Paint Shop Pro
CROSSFIRE O/R
are unset. (PRO Edition only) For more information: http://crossfire.jp/en/dbfw
Jump Start UI for Eclipse
or WindowBuilder Pro, which can be used to further customize and polish your
CROSSFIRE O/R
are unset. (PRO Edition only) For more information: http://crossfire.jp/en/dbfw
System and Hardware Requirement for Windows 8
of at least 1366 x 768. BitLocker To Go requires a USB flash drive (Windows 8 Pro... flash drive (Windows 8 Pro only). If your machine does have BitLocker, it needs
TotalAccess
. then TotalAccess is for you. TotalAccess includes: TotalAccess Pro TotalAccess Server... TotalAccess Pro, and deploy the automatically generated application to the Server
PHP Object Iteration
;; public $b="B"; public $c="C"; protected $pro... the iteration method: One::iteration a=>A b=>B c=>C pro=>
JdbcCallableStatement
JdbcCallableStatement  -------procedure to create oracle9i database-------------------- CREATE OR REPLACE PROCEDURE EXPERIENCE_PRO(ENO NUMBER,E OUT NUMBER)IS d1 date; d2 date; BEGIN select sysdate into d1 from emp where
count statement that saves results on a variable in a java bean
:3306/dev","root","pro"); statement = conn.createStatement
index
Paint Shop Pro Tutorials C++ Tutorials C++ Graphics
use properties file to connect to the database in jsp..
=sun.jdbc.odbc.JdbcOdbcDriver connectionurl=jdbc:odbc:pro username=PRS_ACC password=prs...=DriverManager.getConnection("jdbc:odbc:pro","PRS_ACC","prs"); Statement st=con.createStatement...=sun.jdbc.odbc.JdbcOdbcDriver connectionurl=jdbc:odbc:pro username=PRS_ACC password=prs save
Ques
(System.in); num = scanner.nextInt(); int pro = 1; while (num != 0) { pro *= (num % 10); num = num / 10; } System.out.println("Product of digits: " + pro); } }   =========== Anuj Kumar  
VoIP Broadband
.     VoIP Software and Broadband System  VOIP-Pro... activation and provisioning, VOIP-Pro manages trouble tickets using Inovaware?s.... VOIP-Pro is already capable of supporting a wide range of current and new
Supermarket
pro=new Catalogue(); pro.setProName(name); pro.setProdesc(desc); pro.setPrice(price); catlist.add(pro); display
java - Java Beginners
(true); } public static void main(String z[]) { Table pro=new Table...[]) { ResultSetMetadata pro=new ResultSetMetadata(); pro.dis(); } public void actionPerformed
link+wp-insert - Java Beginners
://forextipshere.com 439 http://pro-gizn.ru 437 http://phantomalert.giftk.com
realsetate+css - Java Beginners
realsetate+css  /* Theme Name: Real Estate Theme URI: Description: Version: 1.0 Author: Author URI: Tags: */ body { margin: 0; padding: 0; background: #63AAD7; color: #000000; font-family: Myriad Pro
MS Access - JDBC
to give the drivername and configure the odbc thats all but ur pro exception
NullPointer Exception - JSP-Servlet
NullPointer Exception  It is in jsp - mysql database program. In this pro. it enters into the statement before try statement. It does not enter into the try statement. I found this by checking out.println("test"); statement
java programming - Java Beginners
void main(String args[]){ SwingProgram pro=new SwingProgram(); } } Thanks
 

 

 

DMCA.com