Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7900685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:01:51+00:00 2026-06-03T09:01:51+00:00

I’m new to C# and I have encountered some problems with my console application

  • 0

I’m new to C# and I have encountered some problems with my console application that I’m recently working on. I am trying to have 3 methods:

getsales to get the sales the user made, calcCom to calculate the commission for the sales and finally main to make them work and establish the program.

I’m having trouble to make those methods work with(in) each other.

After i entered all the sales, the program goes to the else-statement and tells me “invalid entry”. Since i haven’t really gotten to output the variables I didn’t expect any kind of output, but I want the program to tell the user the commission and sale for each person.

Please excuse me if I misused any terms or words, like I said I am new to this language! 😀

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication38
{
class Program
{

    public static void getsales ()
    {
        string inputsales;
        double total = 0;
        double sale = 0;

        for (int salecount = 1; salecount <= 3; ++salecount)
        {

            Console.WriteLine("Enter sale: ");
            inputsales = Console.ReadLine();
            sale = Convert.ToDouble(inputsales);
            total = total + sale;
            Console.WriteLine();
        }
    }

    public static void calcComm ()
    {
        double total = 0;
        double comm = 0;
        comm = total * 0.2;

    }


    static void Main()
    {
        Console.WriteLine("           Sunshine Hot Tubs \n        Sales Commissions Report\n");
        char Letter;
        string name;
        const string name1 = "Andreas";
        const string name2 = "Brittany";
        const string name3 = "Eric";
        string inputLetter;

        Console.WriteLine("Please enter intial or type z to quit");

        inputLetter = Console.ReadLine();
        Letter = Convert.ToChar(inputLetter);



        while (Letter != 'z')
        {

            if (Letter == 'a')
            {
                name = name1;
                getsales();
                calcComm();
            }
               if (Letter == 'b')
               {
                   name = name2;
                   getsales();
                   calcComm();
               }
                   if (Letter == 'e')
                   {
                       name = name3;
                       getsales();
                       calcComm();
                   }

                   else
                   {

                      Console.WriteLine("Invalid entry try again");
                      inputLetter = Console.ReadLine();

                   }


        }
    }
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:01:52+00:00Added an answer on June 3, 2026 at 9:01 am

    I think your problem is you need this:

    if (Letter == 'a')
    {
        name = name1;
        getsales();
        calcComm();
    }
    else if (Letter == 'b')
    {
         name = name2;
         getsales();
         calcComm();
    }
    else if (Letter == 'e')
    {
         name = name3;
         getsales();
         calcComm();
    }
    else
    {
    
        Console.WriteLine("Invalid entry try again");
        inputLetter = Console.ReadLine();
    }
    

    You also need to copy this code after the else block, at the very end of your while loop.

    Console.WriteLine("Please enter intial or type z to quit");
    
    inputLetter = Console.ReadLine();
    Letter = Convert.ToChar(inputLetter);
    

    Also, remove this line from inside the else block. It isn’t needed.

    inputLetter = Console.ReadLine();
    

    You probably intended to display the commision on the console. Change your getsales and calcComm to look like this:

    public static void getsales ()
    {
        string inputsales;
        double total = 0;
        double sale = 0;
    
        for (int salecount = 1; salecount <= 3; ++salecount)
        {
    
            Console.WriteLine("Enter sale: ");
            inputsales = Console.ReadLine();
            sale = Convert.ToDouble(inputsales);
            total = total + sale;
            Console.WriteLine();
        }
        calcComm(total);
    }
    
    public static void calcComm (double total)
    {
        double comm = 0;
        comm = total * 0.2;
        Console.WriteLine(comm);
    }
    

    Then remove all calls to calcComm from the Main method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.