import java.io.*;
class usesales
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
sales ob=new sales();
sales ob1=new sales(001, "Robin", 3, 1000);
System.out.println("Enter sales ID");
int s=Integer.parseInt(br.readLine());
System.out.println("Enter NAME");
String n=br.readLine();
System.out.println("Enter Quantity");
int q=Integer.parseInt(br.readLine());
System.out.println("Enter Price");
int p=Integer.parseInt(br.readLine());
ob.morning();
ob.new_sales(s,n,q,p);
ob.calcbill();
int billret=ob.returnbill();
String nameret=ob.returnname();
System.out.println("The bill on your NAME: " +nameret+ " is = " +billret);
//now using the object created for parametrized constructor
ob1.calcbill();
billret=ob1.returnbill();
nameret=ob1.returnname();
System.out.println("The bill on your NAME: " +nameret+ " is = " +billret);
}
}
class sales
{
int salesid;
String name;
int qty;
int price;
int bill;
sales()
{
salesid=0;
name="";
qty=0;
price=0;
}
sales(int sid, String n, int q, int p)
{
salesid=sid;
name=n;
qty=q;
price=p;
}
void morning()
{
for(int i=1;i<=5;i++)
{
System.out.println("GOOD MORNING");
}
}
void new_sales(int id, String nm, int qt, int pr)
{
salesid=id;
name=nm;
qty=qt;
price=pr;
}
void calcbill()
{
bill=qty*price;
}
int returnbill()
{
return bill;
}
String returnname()
{
return name;
}
}
007
Enter NAME
AMAN
Enter Quantity
10
Enter Price
500
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
The bill on your NAME: AMAN is = 5000
The bill on your NAME: Robin is = 3000
class usesales
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
sales ob=new sales();
sales ob1=new sales(001, "Robin", 3, 1000);
System.out.println("Enter sales ID");
int s=Integer.parseInt(br.readLine());
System.out.println("Enter NAME");
String n=br.readLine();
System.out.println("Enter Quantity");
int q=Integer.parseInt(br.readLine());
System.out.println("Enter Price");
int p=Integer.parseInt(br.readLine());
ob.morning();
ob.new_sales(s,n,q,p);
ob.calcbill();
int billret=ob.returnbill();
String nameret=ob.returnname();
System.out.println("The bill on your NAME: " +nameret+ " is = " +billret);
//now using the object created for parametrized constructor
ob1.calcbill();
billret=ob1.returnbill();
nameret=ob1.returnname();
System.out.println("The bill on your NAME: " +nameret+ " is = " +billret);
}
}
class sales
{
int salesid;
String name;
int qty;
int price;
int bill;
sales()
{
salesid=0;
name="";
qty=0;
price=0;
}
sales(int sid, String n, int q, int p)
{
salesid=sid;
name=n;
qty=q;
price=p;
}
void morning()
{
for(int i=1;i<=5;i++)
{
System.out.println("GOOD MORNING");
}
}
void new_sales(int id, String nm, int qt, int pr)
{
salesid=id;
name=nm;
qty=qt;
price=pr;
}
void calcbill()
{
bill=qty*price;
}
int returnbill()
{
return bill;
}
String returnname()
{
return name;
}
}
OUTPUT:
Enter sales ID007
Enter NAME
AMAN
Enter Quantity
10
Enter Price
500
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
The bill on your NAME: AMAN is = 5000
The bill on your NAME: Robin is = 3000
No comments:
Post a Comment