MUST BE DONE IN C SHARP .NET . PAY ATTENTION TO THE STEPS Create a Class to cont
ID: 3786672 • Letter: M
Question
MUST BE DONE IN C SHARP .NET . PAY ATTENTION TO THE STEPS
Create a Class to contain a customer 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 customer 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.
Initialize a Customer order object instance.
For a custom order detail line, prompt the user to enter a product name, price and amount (each separately). Initialize a customer order detail object instance with the values provided.
Repeats this two more times for a total of three customer order details.
Using the behavior in Customer Order, display the header information in the console.
Using the behavior in Customer Order Detail, display the three order detail lines in the console (each on a separate line).
Pause the console for a final user input before.
Explanation / Answer
using System.IO;
using System;
//created by Rashmi Tiwari
class CustomerOrder{
public String companyName; // Company Type
public String address; // Address
public double salesTax; // Sales Tax
CustomerOrder(){
companyName="XYZ";
address="1/27";
salesTax=5.0;
}
CustomerOrder(String companyName,String address,double salesTax){
this.companyName=companyName;
this.address=address;
this.salesTax=salesTax;
}
void show(){
Console.WriteLine("Welcome to "+ companyName);
}
}
class CustomerOrderDetail{
public String productName; // Product Name
public double price; // Price
public int quantity;
CustomerOrderDetail(){
productName="";
price=0.0;
quantity=0;
}
CustomerOrderDetail(String productName,double price,int quantity){
this.productName=productName;
this.price=price;
this.quantity=quantity;
}
double totalPrice(double salesTaxPrice){
return price+salesTaxPrice;
}
String singleOrderDetail(String productName,double price,Integer quantity){
return "Product "+product+" has Price "+price+" and Quantity is "+quantity;
}
}
class Program
{
static void Main()
{
CustomerOrder c=new CustomerOrder();
CustomerOrderDetail o1=new CustomerOrderDetail("A",500,5);
CustomerOrderDetail o2=new CustomerOrderDetail("B",800,2);
CustomerOrderDetail o3=new CustomerOrderDetail("C",1000,6);
c.show();
Console.WriteLine(o1.productName +" " + o1.price+" "+o1.quantity);
Console.WriteLine(o2.productName +" " + o2.price+" "+o2.quantity);
Console.WriteLine(o3.productName +" " + o3.price+" "+o3.quantity);
Console.ReadLine();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.