Advertisement
virtualideaz

OOD-JAVA program#1

Nov 18th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. Object Oriented Design in Java
  2.  
  3. 1. Create a program that will let the user enter his name, age and salary. The output for name, age and salary is provided in the example.
  4.  
  5. Example :
  6.     Enter name :
  7.     Enter age :
  8.     Enter salary :
  9.  
  10.     Hello! : name
  11.     Age : age
  12.     Salary : salary
  13.  
  14. Program
  15.  
  16. import java.io.*;
  17.  
  18. public class Virtualideaz_Input{
  19.     public static InputStreamReader reader = new InputStreamReader(System.in);
  20.     public static BufferedReader input = new BufferedReader(reader);
  21.     public static void main(String []args) throws Exception {
  22.         //declaration of the variables
  23.  
  24.         String name;
  25.         int age;
  26.         double salary;
  27.  
  28.         //enter details to input values
  29.  
  30.         System.out.println("Enter Name:");
  31.         //input name
  32.         name = input.readLine();
  33.  
  34.         System.out.println("Enter age:");
  35.         //input age
  36.         age = Integer.parseInt(input.readLine());
  37.  
  38.         System.out.println("Enter Salary:");
  39.         //input salary data
  40.         salary = Double.parseDouble(input.readLine());
  41.  
  42.         //print out all the data
  43.         System.out.println("Hello: " +name);
  44.         System.out.println("Age: " +age);
  45.         System.out.println("Salary: " +salary);
  46.  }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement