Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

c# best way to improve

$
0
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace OwenJ
{
    class Program
    {
        public static int cusCost;
        public static int runCost;

       static void Main(string[] args)
        {

            int numHours;
          
            int i = 0;
            while (i != -999)
            {
                Console.WriteLine("Hello, welcome to the car park app");
                Console.Write("");

                Console.WriteLine("Enter Number of Hours (-999 to quit): ");
                numHours = Convert.ToInt32(Console.ReadLine());

                if (numHours == -999)
                {
                    Console.WriteLine("Goodbye");
                    Environment.Exit(0);
                }

                if (numHours > 3)
                {
                    cusCost = (5 + ( numHours - 3));
                }

                else
                {
                    cusCost = 5;
                }

                if(cusCost > 15)
                {
                    cusCost = 15;
                }
              

                Console.WriteLine("Customer Charge :{0} ",cusCost);

                calcMethod();

                i++;             
            }

            Console.ReadLine();
            return;               

    }
       public static void calcMethod()
       {
           
           runCost = cusCost + runCost;

           Console.WriteLine("Total Reciept :{0} ", runCost);
           return;

       }

    }
}

Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>