Click here to Skip to main content
15,891,856 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello I have most completed my program and yet it will not compile. I have checked out the curly braces and they are all aligned. However, I am receiving an error from the very last curly brace stating (Type or namespace definition, or end of file expected). I am sure that this has something to do with the modules, but at this point I don't know what that might be. Any help with this would be greatly appreciated. Thanks

C#
namespace VS_Sand_Box
{
    class Program
    {
        static void Main(string[] args)
        {

        //Enter Varibales
        string customerName, customerState;
        int unitAmount;
        double unitPrice, totalPrice, totalTax;

        //Gather user input
        Console.Write("Enter the customer's name: ");
        customerName = Console.ReadLine();

        Console.Write("Enter the location of transaction i.e.(NJ, FL, or NY): ");
        customerState = Console.ReadLine();

        Console.Write("Enter the amount of units being purchased: ");
        unitAmount = Int32.Parse(Console.ReadLine());

        Console.Write("Enter the price per unit: ");
        unitPrice = Double.Parse(Console.ReadLine());

        //Jump to Module 1
        totalPrice = computeTotal(unitAmount, unitPrice);

        //Jump to Module 2
        totalTax = computeTax(totalPrice, customerState);

        //Continue with output
        Console.WriteLine( "\n\nThe total sales for" + customerName + " are " + totalPrice.ToString("C2"));
        Console.Write("The tax amount is " + totalTax.ToString("C2"));
        Console.WriteLine( "\nThe total with tax is $" +(totalTax + totalPrice));
        Console.ReadLine();
        }

        //Module 1
        public static double computeTotal (int qty, double price)
        {
            return (qty * price);
        }

        //Module 2
        public static double computeTax  (double totalPrices, string customerState)
        {
            if (customerState == "NJ")
                return totalPrices * .07;

            else if (customerState == "FL")
                return totalPrices * .04;

            else if (customerState == "NY")
                return totalPrices * .06;

            else
                return 0;
        }

        }
    }
//Error!!! Type namespace definition, or end-of-file expecedted Error!!!
}
Posted
Comments
[no name] 18-Oct-14 16:30pm    
Are you sure the curly braces match? Sure don't look like it to me.
Member 11136294 18-Oct-14 16:46pm    
You were correct. Thanks

1 solution

C#
<pre lang="text"><pre lang="cs">namespace VS_Sand_Box
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                //Enter Varibales
                string customerName, customerState;
                int unitAmount;
                double unitPrice, totalPrice, totalTax;

                //Gather user input
                Console.Write("Enter the customer's name: ");
                customerName = Console.ReadLine();

                Console.Write("Enter the location of transaction i.e.(NJ, FL, or NY): ");
                customerState = Console.ReadLine();

                Console.Write("Enter the amount of units being purchased: ");
                unitAmount = Int32.Parse(Console.ReadLine());

                Console.Write("Enter the price per unit: ");
                unitPrice = Double.Parse(Console.ReadLine());

                //Jump to Module 1
                totalPrice = computeTotal(unitAmount, unitPrice);

                //Jump to Module 2
                totalTax = computeTax(totalPrice, customerState);

                //Continue with output
                Console.WriteLine("\n\nThe total sales for " + customerName + " are " + totalPrice.ToString("C2"));
                Console.Write("The tax amount is " + totalTax.ToString("C2"));
                Console.WriteLine("\nThe total with tax is $" + (totalTax + totalPrice));
                Console.ReadLine();
            }
        }

        //Module 1
        public static double computeTotal (int qty, double price)
        {
            return (qty * price);
        }

        //Module 2
        public static double computeTax  (double totalPrices, string customerState)
        {
            if (customerState == "NJ")
                return totalPrices * .07;

            else if (customerState == "FL")
                return totalPrices * .04;

            else if (customerState == "NY")
                return totalPrices * .06;

            else
                return 0;
        }
    }
}
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 19-Oct-14 1:03am    
This is not an answer. Who would possibly be interested to look at this?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900