C # travel agency calculated in accordance with this tour transportation travel month and price control program flow if switch statement

A travel agency for a tourist project original price is 8800, based on user input travel season and the choice is selected flights travel or motor car travel, different discounts, from May to October is the peak season, flights to travel 10% off select EMU travel hit 7.5 fold other off-season time, flight travel to play six pack, motor car travel choose to play three fold. Please calculated based on travel and transportation this month tours price
for this program is not set too complex exception handling

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

namespace 旅行社
{
    class Program
    {
        static void Main(string[] args)
            {
                int month;
                String flight;
                String train;
                double Disprice;
                double price = 8800.0;
         
                Console.WriteLine("请预约你要出行的日期(月份):");
                month = int.Parse(Console.ReadLine());
                Console.WriteLine("请预约你要出行的方式:");
                String choice = Console.ReadLine();
                flight = choice;
                train = choice;
            if (5<=month &&  month<=10)< p="">
            {
                switch (choice)
                {

                    case "flight":
                            Disprice = price * 0.9;
                            Console.WriteLine("您出行的月份为{0},出行方式为{1},所需费用为{2}", month, flight, Disprice);
                        break;
                    case "train":
                            Disprice = price * 0.75;
                            Console.WriteLine("您出行的月份为{0},出行方式为{1},所需费用为{2}", month, train, Disprice);
                        break;
                    default:
                        Console.WriteLine("没有此出行方式");
                        break;
                }
                    
            }
            
            else {
                switch (choice)
                {

                    case "flight":
                        Disprice = price * 0.6;
                        Console.WriteLine("您出行的月份为{0},出行方式为{1},所需费用为{2}", month, flight, Disprice);
                        break;
                    case "train":
                        Disprice = price * 0.3;
                        Console.WriteLine("您出行的月份为{0},出行方式为{1},所需费用为{2}", month, train, Disprice);
                        break;
                    default:
                        Console.WriteLine("没有此出行方式");
                        break;
                }
            }
            Console.ReadLine();
        } 
        
    }
}
Released seven original articles · won praise 0 · Views 73

Guess you like

Origin blog.csdn.net/HCY008042/article/details/104659382