Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Can someone help?

Can someone help?

Scheduled Pinned Locked Moved C#
csharpsaleshelpquestionlearning
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larkdog
    wrote on last edited by
    #1

    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

    C S 2 Replies Last reply
    0
    • L Larkdog

      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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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!

      L 1 Reply Last reply
      0
      • C Colin Angus Mackay

        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!

        L Offline
        L Offline
        Larkdog
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • L Larkdog

          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

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          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 read double 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!

          L 1 Reply Last reply
          0
          • C Colin Angus Mackay

            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 read double 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!

            L Offline
            L Offline
            Larkdog
            wrote on last edited by
            #5

            Thank you, That helped alot. I know this seems very rudemtary but it's like learning spanish in 7 weeks.

            C 1 Reply Last reply
            0
            • L Larkdog

              Thank you, That helped alot. I know this seems very rudemtary but it's like learning spanish in 7 weeks.

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              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!

              J 1 Reply Last reply
              0
              • C Colin Angus Mackay

                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!

                J Offline
                J Offline
                je_gonzalez
                wrote on last edited by
                #7

                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.

                C 1 Reply Last reply
                0
                • L Larkdog

                  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

                  S Offline
                  S Offline
                  sreejith ss nair
                  wrote on last edited by
                  #8

                  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 **************************

                  C 1 Reply Last reply
                  0
                  • J je_gonzalez

                    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.

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #9

                    :-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!

                    1 Reply Last reply
                    0
                    • S sreejith ss nair

                      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 **************************

                      C Offline
                      C Offline
                      Colin Angus Mackay
                      wrote on last edited by
                      #10

                      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!

                      S 1 Reply Last reply
                      0
                      • C Colin Angus Mackay

                        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!

                        S Offline
                        S Offline
                        sreejith ss nair
                        wrote on last edited by
                        #11

                        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 **************************

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups