Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, the ending is not working for me . Can please help me . using System; using static System.Console; using System.Globalization; class SalesTransaction { private

Hello, the ending is not working for me.
Can please help me.
using System;
using static System.Console;
using System.Globalization;
class SalesTransaction
{
private string name;
private double salesAmount;
private double commission;
private static readonly double RATE =0.1;
public SalesTransaction(string name, double salesAmount, double rate)
{
this.name = name;
this.salesAmount = salesAmount;
this.commission = salesAmount * rate;
}
public SalesTransaction(string name, double salesAmount)
{
this.name = name;
this.salesAmount = salesAmount;
this.commission =0;
}
public SalesTransaction(string name)
{
this.name = name;
this.salesAmount =0;
this.commission =0;
}
public static double GetRate()
{
return RATE;
}
public static SalesTransaction operator +(SalesTransaction transaction1, SalesTransaction transaction2)
{
string combinedName = $"{transaction1.name} and {transaction2.name}";
double combinedSalesAmount = transaction1.salesAmount + transaction2.salesAmount;
double combinedCommission = combinedSalesAmount * RATE;
return new SalesTransaction(combinedName, combinedSalesAmount, RATE);
}
public void Display()
{
WriteLine("Salesperson: {0}", name);
WriteLine("Sales Amount: {0}", salesAmount.ToString("C", CultureInfo.GetCultureInfo("en-US")));
WriteLine("Commission: {0}", commission.ToString("C", CultureInfo.GetCultureInfo("en-US")));
WriteLine("Commission Rate: {0}", RATE.ToString("P", CultureInfo.InvariantCulture)); // Display rate as percentage
WriteLine();
}
}
class SalesTransactionDemo
{
static void Main()
{
SalesTransaction transaction1= new SalesTransaction("John Doe", 5000);
SalesTransaction transaction2= new SalesTransaction("Jane Smith", 7500);
SalesTransaction combinedTransaction = transaction1+ transaction2;
Display(transaction1);
Display(transaction2);
Display(combinedTransaction);
DisplayTotal(transaction1, transaction2, combinedTransaction);
}
public static void Display(SalesTransaction transaction)
{
WriteLine("Individual Transaction:");
transaction.Display();
}
public static void DisplayTotal(params SalesTransaction[] transactions)
{
WriteLine("Total Sales Amount: {0}", transactions.Sum(t => t.GetSalesAmount()).ToString("C", CultureInfo.GetCultureInfo("en-US")));
WriteLine("Total Commission: {0}", transactions.Sum(t => t.GetCommission()).ToString("C", CultureInfo.GetCultureInfo("en-US")));
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Identify the cause of a performance problem. page 363

Answered: 1 week ago