Can someone help?
-
I am very new to C#, I have tried to make this work but it is very difficult learning this new language. Scenario: Three salespeople work at Sunshine Hot Tubs - Andrea, Brittany, and Eric. Write a program that prompts the user for a saleperson's initial. While the user does not type 'Z', continue by promting for the amount of a sale that salesperson made. Calculate the saleperson's Commission as 10 percent of the sale amount, and add the commission to a running total for that salesperson. After the user types 'Z' for an initial, display each salesperson's total commission earned. Here's what I have so far: (I have commented out compiler errors) using System; namespace TubSales {//Namespace class SalesPeople {//Class static void Main(string[] args) {// Main char response; //double Comm; Console.WriteLine("Please enter your first initial, or type Z to to find your total commision."); response = GetChar(); while (response == 'A' || response == 'a') { Console.WriteLine("Enter the amount of sales you had."); //CalculateSales(); } while (response == 'B' || response == 'b') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } while (response == 'E' || response == 'e') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } if (response == 'Z' || response == 'z') { Console.WriteLine("Andrea's total commision is {0}.");//,Comm); Console.WriteLine("Brittany's total commision {0}.");//,Comm); Console.WriteLine("Eric's total commision {0}.");//,Comm); } Console.WriteLine("Have a Nice Day!"); }//Main //public static double CalculateSales() //{ //double Sales; //double Commision; //Commision = .10; //double answer; //inputString = Console.ReadLine(Sales); //return answer; //Comm = Sales * Commision; //} public static char GetChar() { string inputString; char answer; inputString = Console.ReadLine(); answer = Convert.ToChar(inputString); return answer; } }//Class }//Namespace
-
I am very new to C#, I have tried to make this work but it is very difficult learning this new language. Scenario: Three salespeople work at Sunshine Hot Tubs - Andrea, Brittany, and Eric. Write a program that prompts the user for a saleperson's initial. While the user does not type 'Z', continue by promting for the amount of a sale that salesperson made. Calculate the saleperson's Commission as 10 percent of the sale amount, and add the commission to a running total for that salesperson. After the user types 'Z' for an initial, display each salesperson's total commission earned. Here's what I have so far: (I have commented out compiler errors) using System; namespace TubSales {//Namespace class SalesPeople {//Class static void Main(string[] args) {// Main char response; //double Comm; Console.WriteLine("Please enter your first initial, or type Z to to find your total commision."); response = GetChar(); while (response == 'A' || response == 'a') { Console.WriteLine("Enter the amount of sales you had."); //CalculateSales(); } while (response == 'B' || response == 'b') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } while (response == 'E' || response == 'e') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } if (response == 'Z' || response == 'z') { Console.WriteLine("Andrea's total commision is {0}.");//,Comm); Console.WriteLine("Brittany's total commision {0}.");//,Comm); Console.WriteLine("Eric's total commision {0}.");//,Comm); } Console.WriteLine("Have a Nice Day!"); }//Main //public static double CalculateSales() //{ //double Sales; //double Commision; //Commision = .10; //double answer; //inputString = Console.ReadLine(Sales); //return answer; //Comm = Sales * Commision; //} public static char GetChar() { string inputString; char answer; inputString = Console.ReadLine(); answer = Convert.ToChar(inputString); return answer; } }//Class }//Namespace
What were the compiler errors?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
What were the compiler errors?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
1. Use of unassigned local variable 'Comm' 2. The name 'inputString' does not exist in the class or namespace 'TubSales.SalesPeople' 3. The name 'Comm' does not exist in the class or namespace 'TubSales.SalesPeople' 4. Unreachable code detected
1. you have declared a variable called Comm in the Main() method, but you don't assign anything to it. You appear to try to do this in the CalculateSales() method, but this is a different scope and cannot see the Comm in the Main() method. TIP: the curly braces {} are scope delimiters if you declare something inside a set of braces then code outside them cannot see it. 2. In the CalculateSales() method you have not declared a variable called inputString. Change the line to read
string inputString = Console.ReadLine(Sales);
3. See also (1) above. You need to create a variable called Comm in the CalculateSales() method. The line should readdouble Comm = Sales * Commision;
4. Swap the last two lines of the CalculateSales() method. After a return statement no more code can run, it is therefore unreachable. Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
1. you have declared a variable called Comm in the Main() method, but you don't assign anything to it. You appear to try to do this in the CalculateSales() method, but this is a different scope and cannot see the Comm in the Main() method. TIP: the curly braces {} are scope delimiters if you declare something inside a set of braces then code outside them cannot see it. 2. In the CalculateSales() method you have not declared a variable called inputString. Change the line to read
string inputString = Console.ReadLine(Sales);
3. See also (1) above. You need to create a variable called Comm in the CalculateSales() method. The line should readdouble Comm = Sales * Commision;
4. Swap the last two lines of the CalculateSales() method. After a return statement no more code can run, it is therefore unreachable. Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Thank you, That helped alot. I know this seems very rudemtary but it's like learning spanish in 7 weeks.
Your welcome. Also: Es posible aprender un nivel bueno de la idioma española en siete semanas con el curso de Michel Thomas y después de qué, imerción total en la cultura española. (It's been over a year since I did any Spanish so I may have made some mistakes)
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Your welcome. Also: Es posible aprender un nivel bueno de la idioma española en siete semanas con el curso de Michel Thomas y después de qué, imerción total en la cultura española. (It's been over a year since I did any Spanish so I may have made some mistakes)
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
Es posible aprender un buen nivel de español en siete semanas con el curso de Michel Thomas y despues de el cual, una inmersión total el la cultura española.
-
I am very new to C#, I have tried to make this work but it is very difficult learning this new language. Scenario: Three salespeople work at Sunshine Hot Tubs - Andrea, Brittany, and Eric. Write a program that prompts the user for a saleperson's initial. While the user does not type 'Z', continue by promting for the amount of a sale that salesperson made. Calculate the saleperson's Commission as 10 percent of the sale amount, and add the commission to a running total for that salesperson. After the user types 'Z' for an initial, display each salesperson's total commission earned. Here's what I have so far: (I have commented out compiler errors) using System; namespace TubSales {//Namespace class SalesPeople {//Class static void Main(string[] args) {// Main char response; //double Comm; Console.WriteLine("Please enter your first initial, or type Z to to find your total commision."); response = GetChar(); while (response == 'A' || response == 'a') { Console.WriteLine("Enter the amount of sales you had."); //CalculateSales(); } while (response == 'B' || response == 'b') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } while (response == 'E' || response == 'e') { Console.WriteLine("Enter the amount of sales you had."); Console.ReadLine(); } if (response == 'Z' || response == 'z') { Console.WriteLine("Andrea's total commision is {0}.");//,Comm); Console.WriteLine("Brittany's total commision {0}.");//,Comm); Console.WriteLine("Eric's total commision {0}.");//,Comm); } Console.WriteLine("Have a Nice Day!"); }//Main //public static double CalculateSales() //{ //double Sales; //double Commision; //Commision = .10; //double answer; //inputString = Console.ReadLine(Sales); //return answer; //Comm = Sales * Commision; //} public static char GetChar() { string inputString; char answer; inputString = Console.ReadLine(); answer = Convert.ToChar(inputString); return answer; } }//Class }//Namespace
hi, Better try to consice your question with main points. Otherwise no one will try to read. See in C# what every input you are giving through console is treating as string. And it's your headache to convert it into your required form. You can use Console.Read() insted of Console.Readline(). static void Main(string[] args) { char Responce; Console.WriteLine("Please enter your first initial, or type Z to to find your total commision."); Responce=Convert.ToChar(Console.Read()); Console.WriteLine(Responce.ToString()); } :-O ************************** S r e e j i t h N a i r **************************
-
Es posible aprender un buen nivel de español en siete semanas con el curso de Michel Thomas y despues de el cual, una inmersión total el la cultura española.
:-O Thanks :-D
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
hi, Better try to consice your question with main points. Otherwise no one will try to read. See in C# what every input you are giving through console is treating as string. And it's your headache to convert it into your required form. You can use Console.Read() insted of Console.Readline(). static void Main(string[] args) { char Responce; Console.WriteLine("Please enter your first initial, or type Z to to find your total commision."); Responce=Convert.ToChar(Console.Read()); Console.WriteLine(Responce.ToString()); } :-O ************************** S r e e j i t h N a i r **************************
sreejith ss nair wrote: Better try to consice your question with main points. Otherwise no one will try to read. :confused: By the time you posted this, I'd already answered Larkdog and his problem was solved 11 hours previously.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
sreejith ss nair wrote: Better try to consice your question with main points. Otherwise no one will try to read. :confused: By the time you posted this, I'd already answered Larkdog and his problem was solved 11 hours previously.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
hi, Sorry colin i didn't seen any post at that time. His question is there at the end of descussion record and i my net is too very slow. I am really sorry. What i mean by that is try to submit consicely. If it is complex problem we need to give detailed explanation. that's it.:doh: ************************** S r e e j i t h N a i r **************************