Create a Class to contain a Client order Create attributes of that class to stor
ID: 3663618 • Letter: C
Question
Create a Class to contain a Client order
Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes.
Create a class constructor without parameters that initializes the attributes to default values.
Create a class constructor with parameters that initializes the attributes to the passed in parameter values.
Create a behavior of that class to generate a welcome message that includes the company name.
Create a Class to contain a Client order detail row
Create attributes of that class to store Product Name, Price and Amount. Create a public property for each of these attributes.
Create a constructor without parameters that set all the attributes to an empty string or zero.
Create a constructor with parameters that sets all the attributes to the passed in parameters.
Create a behavior that, when provided a sales tax value, returns the total price for a detail row including sales tax.
Create a behavior that, when provided a product name, price and quantity, returns a single line order detail.
Explanation / Answer
class client_order
{
String comp_name, address;
double st;
client_order()
{
comp_name="aaa";
address="bbb";
st=10;
}
client_order(String n, String a, double s)
{
comp_name=n;
address=a;
st=s;
}
void disp()
{
System.out.println("Welcome "+comp_name);
}
}
class client_or_dt
{
String pname;
double price, amt;
client_or_dt()
{
pname="ccc";
price=20;
amt=50;
}
client_or_dt(String p, double pr, double a)
{
pname=p;
price=pr;
amt=a;
}
double tot_val(double st)
{
return (amt*st/100);
}
}