Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class library{
- public int bookid;
- protected String name;
- private double price;
- void setprice(double a){
- price=a;
- }
- double getprice(){
- return price;
- }
- }
- class use{
- public static void main(String[] args){
- Scanner input= new Scanner(System.in);
- library ob = new library();
- System.out.println("Enter Book Name: ");
- ob.name= input.next();
- System.out.println("Enter Book ID: ");
- ob.bookid=input.nextInt();
- System.out.println("Enter Book Price: ");
- double b=input.nextDouble();
- ob.setprice(b);
- System.out.println("Name: "+ob.name+" ID: "+ob.bookid+" Price: "+ob.getprice());
- }
- }
- Output:
- Enter Book Name:
- Programming
- Enter Book ID:
- 12334
- Enter Book Price:
- 570
- Name: Programming ID: 12334 Price: 570.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement