Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question/problem is: Danielle, Edward, and Francis are three salespeople at Holiday Homes. Write an application named HomeSales that prompts the user for a salesperson

The question/problem is:

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".

This is the error: Program accepts both upper and lower case value for a salesperson's initial Input D 10 d 5 Z Output Enter a salesperson initial: Enter amount of sale: Enter a salesperson initial: Enter amount of sale: Enter a salesperson initial: Danielle sold: $15.00 Edward sold: $0.00 Francis sold: $0.00 Total sales were: $15.00 Danielle sold the most Results Danielle\ssold\s*\$15\.00Edward\ssold\s*\$0\.00Francis\ssold\s*\$0\.00 Expected Output Danielle\ssold\s*\$15\.00Edward\ssold\s*\$0\.00Francis\ssold\s*\$0\.00 0

This is my code as of now: using System; using System.Globalization; class HomeSales { static void Main() { string initial = ""; int dSale = 0; int eSale = 0; int fSale = 0; int total = 0; while (initial != "z") { Console.WriteLine("Enter a salesperson initial:"); initial = Console.ReadLine().ToLower(); if(initial == "d" || initial == "e" || initial == "f"){ Console.WriteLine("Enter amount of sale:"); int amount = Convert.ToInt32(Console.ReadLine()); if (initial == "d") dSale += amount; else if (initial == "e") eSale += amount; else if (initial == "f") fSale += amount; }else{ if(initial != "z"){ Console.WriteLine("Sorry - invalid salesperson"); } } } total = dSale + eSale + fSale; Console.WriteLine("Danielle sold: {0}", dSale.ToString("C", CultureInfo.GetCultureInfo("en-US"))); Console.WriteLine("Edward sold: {0}", eSale.ToString("C", CultureInfo.GetCultureInfo("en-US"))); Console.WriteLine("Francis sold: {0}", fSale.ToString("C", CultureInfo.GetCultureInfo("en-US"))); Console.WriteLine("Total sales were: {0}", total.ToString("C", CultureInfo.GetCultureInfo("en-US"))); if(dSale > eSale && dSale > fSale){ Console.WriteLine("Danielle sold the most"); }else if(eSale > dSale && eSale > fSale){ Console.WriteLine("Edward sold the most"); }else if(fSale > dSale && fSale > eSale){ Console.WriteLine("Francis sold the most"); }else { Console.WriteLine("There was a tie"); } } }

If you could respond back with a solution quickly it would be much appreciated.

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What is Blume's formula? When would you want to use it in practice?

Answered: 1 week ago

Question

explain what is meant by the terms unitarism and pluralism

Answered: 1 week ago