开发者

program falling apart at the "if" statement and forcing a category "B"

开发者 https://www.devze.com 2023-04-09 20:51 出处:网络
ok so this program keep falling apart at the first \"if\" statement and keep bringing me to caragory B any tips?where is it failing? what code needs to be added or taken out?

ok so this program keep falling apart at the first "if" statement and keep bringing me to caragory B any tips?where is it failing? what code needs to be added or taken out?

using System;

class Program
{
    enum Numbers { standard = 1, express = 2, same = 3 };

    const int A = 1, B = 2;
    const int Y = 3, N = 4;
    static void Main()
     {

        double cost, LB;
        int Number_of_items ;
        int myNumbers;
        char catagory = 'A';
        char surcharge = 'Y';

        Console.WriteLine("please enter the type of shiping you want");
        Console.WriteLine("Enter 1:standard shipping.");
        Console.WriteLine("Enter 2:express shipping.");
        Console.WriteLine("Enter 3:same day shipping.");

        myNumbers = int.Parse(Console.ReadLine());
        switch ((Numbers)myNumbers)
        { 
            case Numbers.standard:
                Console.WriteLine("thankyou for chooseing standerd shipping");
                Console.WriteLine("please choose a catagory");
                Console.Write("Type A or B to make your selection");
                catagory = char.Parse(Console.ReadLine());
                {      if (catagory==A)
                {
                    Console.Write("please enter the number of items");
                    Number_of_items = int.Parse(Console.ReadLine());
                    cost = 3 * Number_of_items;

                    Console.Write("is this shipment going to alaska or Hawaii? (Y or N)");
                    if (surcharge==Y)
                    {
                        cost = cost + 2.50;

                        Console.WriteLine("Total cost is {0}." , cost);
                    }
                    else 
                        Console.WriteLine("total cost is {0}." , cost);


                }
                else
                    Console.Write("please enter the weight in pounds");
               LB =  double.Parse(Console.ReadLine());
                cost = 1.45 * LB;
                Console.WriteLine("is this shipment going to alaska or Hawaii? (Y or N)");
        }
                if (surcharge==Y)
                {
                    cost = cost + 2.50;

                        Console.WriteLine("Total cost is {0}." , cost);
                }
                else 
                        Console.WriteLine("total cost is {0}." , cost);

                break;


                case Numbers.express:
                Console.WriteLine("thankyou for chooseing Express Shipping");
                Console.WriteLine("please choose a catagory");
                Console.Write("Type A or B to make your selection");
                catagory = char.Parse(Console.ReadLine());
                    {       if (catagory==A)
                        Console.Write("please enter the number of items");
                        Number_of_items = int.Parse(Console.ReadLine());
                        cost = 4 * Number_of_items;
                        {
                    Console.Write("is this shipment going to alaska or Hawaii? (Y or N)");
                    if (surcharge==Y)
                    {
                        cost = cost + 5.00;

                        Console.WriteLine("Total cost is {0}." , cost);
                    }
                    else 
                        Console.WriteLine("total cost is {0}." , cost);


                    }
                        if (surcharge==B)


                            Console.Write("please enter the weight in pounds");
               LB =  double.Parse(Console.ReadLine());
                cost = 2.50 * LB;
                Console.WriteLine("is this shipment going to alaska or Hawaii? (Y or N)");
                    }
                if (surcharge==Y)
                {
                    cost = cost + 5.00;

                        Console.WriteLine("Total cost is {0}." , cost);
                }
                else 
                        Console.WriteLine("total cost is {0}." , cost);
            break;





                case Numbers.same:
                Console.WriteLine("thankyou for chooseing Same Day Shipping");
                Console.WriteLine("please choose a catagory");
                Console.Write("Type A or B to make your selection");
                catagory = char.Parse(Console.ReadLine());
                if (catagory == A)
                    Console.Write("please enter the number of items");
                    Number_of_items = int.Parse(Console.ReadLine());
                    cost = 5.50 * Number_of_items;

                    Console.Write("is this shipment going to alaska or Hawaii? (Y or N)");
                    if (surcharge==Y)
                    {
                        cost = cost + 8.00;

                        Console.WriteLine("Total cost is {0}." , cost);
                    }
                    else 
                        Console.WriteLine("total cost is {0}." , cost);



                if (surcharge==B)

                    Console.Write("please enter the weight in pounds");
               LB 开发者_如何转开发=  double.Parse(Console.ReadLine());
                cost = 3.00 * LB;
                Console.WriteLine("is this shipment going to alaska or Hawaii? (Y or N)");

                if (surcharge==Y)
                {
                    cost = cost + 8.00;

                        Console.WriteLine("Total cost is {0}." , cost);
                }
                else 
                        Console.WriteLine("total cost is {0}." , cost);

                break;
        }
  Console.ReadLine();

    }//End Main()
}//End class Program


A is an int variable to which you assigned the value 1. You probably meant to do: if (catagory=='A') not if (catagory==A)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号