Java Tutorial

 
 
 
 
import java.io.*;
import java.util.*;

class  Inventory
{
    static DataInputStream din = new DataInputStream(System.in);
    static StringTokenizer st;
    public static void main(String[] args) throws IOException
    {
           DataOutputStream dos = new DataOutputStream(
                          new    FileOutputStream(\"Invent.txt\"));

           //Reading from the console
           System.out.print(\"Enter code number : \");
           System.out.flush();
           st = new StringTokenizer(din.readLine());
           int code = Integer.parseInt(st.nextToken());

           System.out.print(\"Enter Item : \");
           System.out.flush();
           st =new StringTokenizer(din.readLine());
           int item = Integer.parseInt(st.nextToken());

           System.out.print(\"Enter Cost of Item : \");
           System.out.flush();
           st =new StringTokenizer(din.readLine());
           double cost = new Double(st.nextToken()).doubleValue();

           //Writing to the file Invent.txt
           dos.writeInt(code);
           dos.writeInt(item);
           dos.writeDouble(cost);
           dos.close();

           //processing data from the file
           DataInputStream dis = new DataInputStream( new 
                      FileInputStream(\"Invent.txt\"));
           int codeNumber = dis.readInt();
           int  totalItems = dis.readInt();
           double itemCost = dis.readDouble();
           double totalCost = totalItems * itemCost;

           //Writing to Console
           System.out.println(\"\\nCode Number : \" + codeNumber);
           System.out.println(\"Item cost          : \" + itemCost);
           System.out.println(\"Total Items       : \" + totalItems);
           System.out.println(\"Total Cost         : \" + totalCost);
    }
}

    Related Post:
  1. Program to declare and initialize Integer variables and print them on the Standard Output Device

  2. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  3. Program to show an example of Multiple Levels of Inheritance

  4. Program to show an example of creating a String object from a StringBuffer Object

  5. Program that accepts a shopping list of five items from the command line and stores them in vector

  6. Biological Sequence Allignment Using Dynamic Programing

  7. Program to show the use of Bitwise Operator (|) OR

  8. Program to represent a bank account

  9. RMI application for counting factorial of a given number.

  10. Program to Display Output in triangular shape

  11. Program to generate Fibonacci Series of a given number

  12. An applet program to draw Polygon Graph with given data

  13. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  14. Program to show the use of If Statement

  15. An applet program showing Clicked Event on canvas

  16. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  17. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  18. Program to show an example of overloading constructors in a class to initialize its data members

  19. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  20. Program to show an example of using a Static Nested Class

 
 
Didn't find what you were looking for? Find more on Program of inventory management and demonstrating interactive input and output