Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# coing Instructions : Danielle, Edward, and Francis are three salespeople at Holiday Homes. Write an application named HomeSales that prompts the user for a

C# coing

Instructions:

Danielle, Edward, and Francis are three salespeople at Holiday Homes. Write an application named HomeSales that prompts the user for a salesperson initial (D, E, or F) input as a string. Either uppercase or lowercase initials are valid. While the user does not type Z, continue by prompting for the amount of a sale. Issue the error message "Sorry - invalid salesperson" for any invalid initials entered. Keep a running total of the amounts sold by each salesperson. After the user types Z or z for an initial, display each salespersons total, a grand total for all sales, and the name of the salesperson with the highest total unless there is a tie. If there is a tie, indicate this in the program's output with the message: "There was a tie".

An example of the program is shown below:

Enter a salesperson initial >> D Enter amount of sale >> 10 Enter next salesperson intital or Z to quit >> d Enter amount of sale >> 2 Enter next salesperson intital or Z to quit >> E Enter amount of sale >> 15 Enter next salesperson intital or Z to quit >> f Enter amount of sale >> 9 Enter next salesperson intital or Z to quit >> Z Danielle sold $12.00 Edward sold $15.00 Francis sold $9.00 Total sales were $36.00 Edward sold the most

In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));

My code so far:

using System;

using static System.Console;

using System.Globalization;

class HomeSales

{

static void Main()

{

// Write your main here.

char ch='D';

int sum=0, sumD=0, sumE=0, sumF=0, value, higherSale;

string highestSalesPerson;

while(true)

{

Console.WriteLine("Enter the" + " intitial for salesperson" + " D, E, F and Z to terminate");

ch = Convert.ToChar(Console.ReadLine());

if(ch=='d' || ch=='D')

{

Console.WriteLine("Please" + " enter the sale amount");

value = Convert.ToInt32(Console.ReadLine());

sum = sum + value;

sumD=sumD + value;

}

else if (ch == 'e' || ch == 'E')

{

Console.WriteLine("Please"+"enter the sale amount");

value = Convert.ToInt32(Console.ReadLine());

sum = sum+value;

sumE = sumE + value;

}

else if (ch =='f' || ch=='F')

{

Console.WriteLine("Please"+" enter the sale amount");

value = Convert.ToInt32(Console.ReadLine());

sum = sum + value;

sumF = sumF + value;

}

else if (ch == 'z' || ch == 'Z')

{

break;

}

else

{

Console.WriteLine("Please"+"enter a valid initial");

}

}

if (sumD>sumE&&sumD>sumF)

{

highestSalesPerson="Danielle";

higherSale=sumD;

}

else if (sumE>sumF)

{

highestSalesPerson="Edward";

higherSale=sumE;

}

else

{

highestSalesPerson="Francis";

higherSale=sumF;

}

Console.WriteLine(" Totalsale "+"of Danielle is...: {0:c}", sumD);

Console.WriteLine(" Totalsale "+"of Edward is...: {0:c}", sumE);

Console.WriteLine(" Totalsale "+"of Francise is...: {0:c}", sumF);

Console.WriteLine(" Grand "+"Total sale is...: {0:c}", sum);

Console.WriteLine(" Highest "+"sales person is...: {0}"+" Highest sale is...:{1:c}", highestSalesPerson, higherSale);

Console.ReadLine();

}

}

Things I am missing that I need help with:

1. Program accepts both upper and lower case value for a salesperson's initial

Input

D 10 d 5 Z 

Output

Enter the intitial for salesperson D, E, F and Z to terminate Please enter the sale amount Enter the intitial for salesperson D, E, F and Z to terminate Please enter the sale amount Enter the intitial for salesperson D, E, F and Z to terminate Totalsale of Danielle is...: 15.00 Totalsale of Edward is...: 0.00 Totalsale of Francise is...: 0.00 Grand Total sale is...: 15.00 Highest sales person is...: Danielle Highest sale is...:15.00 

Results

Danielle\ssold\s*\$15\.00

Edward\ssold\s*\$0\.00

Francis\ssold\s*\$0\.00

Expected Output

Danielle\ssold\s*\$15\.00

Edward\ssold\s*\$0\.00

Francis\ssold\s*\$0\.00

2.The program indicates a tie if there is one

Input

D 3 E 3 F 3 Z 

Output

Enter the intitial for salesperson D, E, F and Z to terminate Please enter the sale amount Enter the intitial for salesperson D, E, F and Z to terminate Pleaseenter the sale amount Enter the intitial for salesperson D, E, F and Z to terminate Please enter the sale amount Enter the intitial for salesperson D, E, F and Z to terminate Totalsale of Danielle is...: 3.00 Totalsale of Edward is...: 3.00 Totalsale of Francise is...: 3.00 Grand Total sale is...: 9.00 Highest sales person is...: Francis Highest sale is...:3.00 

Expected Output

There was a tie

3.

The program displays an error message for invalid initials

Input

r Z 

Output

Enter the intitial for salesperson D, E, F and Z to terminate Pleaseenter a valid initial Enter the intitial for salesperson D, E, F and Z to terminate Totalsale of Danielle is...: 0.00 Totalsale of Edward is...: 0.00 Totalsale of Francise is...: 0.00 Grand Total sale is...: 0.00 Highest sales person is...: Francis Highest sale is...:0.00 

Expected Output

Sorry - invalid salesperson

Please fix my code and make it where I can copy and paste the code. THANK YOU

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_2

Step: 3

blur-text-image_3

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions