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. An applet of displaying simple moving banner

  2. Program to search an element in an array using Linear Search

  3. Corba program to Write a Echo server and client with UDP server and client

  4. Program to print triangle of numbers

  5. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  6. Even number ,Prime no. ,Factorial of a number

  7. Program to read the table elements into a two-dimensional array temperature

  8. Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

  9. corba program of client and a DNS server where given a URL the server sends back an IP address

  10. Socket program of HTTP Server

  11. Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet

  12. An applet program to display Horizontal Color Bar

  13. Program to show the use of operator (<<) Shift Left filling with zero from the right

  14. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  15. Program to copy the elements of an array into another array in reverse order and print them

  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 declare, initialize and print a String object

  18. Program to show the use of Bitwise Operator (^) XOR (Exclusive OR)

  19. Program to show an example of using a Static Nested Class outside the Top-Level Class

  20. Program of linear search

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