Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

I want to use Excel table and give it if else conditions in C# (IDE Visual studio 2012 )

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

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Year of Construction:");
            int Year = Convert.ToInt32(Console.ReadLine()); //inputs
            Console.WriteLine("Enter Span of the Bridge:");
            double Span = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter the Slab thickness:");
            int Thickness = Convert.ToInt32(Console.ReadLine()); // thickness = slab
            Console.WriteLine("Enter Width of the Bridge:");
            int Width = Convert.ToInt32(Console.ReadLine()); // roadway = width
            if (Year < 1930) //Factor for age
            {

                Double Thickness1 = Math.Round(9.00 / 10.00) * Thickness;
                Console.WriteLine("The New Thickness is " + Thickness1);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("The Thickness Remains Same as " + Thickness);
                Console.ReadLine();
            }
            if (Thickness == 6) // selecting table
            {
                Console.WriteLine("Looking into 6 inch Slab thickness Table . . .");
                Console.ReadLine();
                if (Span == 5.00) // selecting span row
                {
                    Console.WriteLine("Now selecting the Roadway column. . ."); 
                    Console.ReadLine();
                    if (Width <= 24) // selection critera 1 , select 20ft roadway
                    {
                        Console.WriteLine("For ONE WAY: ");
                        Console.WriteLine("(a) Wheel = 150");
                        Console.WriteLine("(b) Track = +150");
                        Console.WriteLine("For TWO WAY: "); 
                        Console.WriteLine("(a) Wheel = +40");  
                        Console.WriteLine("(b) Track = +30");
                        Console.ReadLine();
                    }
                    if ((Width > 24) && (Width < 30)) select 40ft roadway with 18% rduction factor
                    {
                        Console.WriteLine("For ONE WAY: ");
                        Console.WriteLine("(a) Wheel = +123");
                        Console.WriteLine("(b) Track = +123");
                        Console.WriteLine("For TWO WAY: ");
                        Console.WriteLine("(a) Wheel = 123");
                        Console.WriteLine("(b) Track = +98.4");
                        Console.ReadLine();
                    }
                    if (Width >= 30) select 40ft roadway
                    {
                        Console.WriteLine("For ONE WAY: ");
                        Console.WriteLine("(a) Wheel = 150");
                        Console.WriteLine("(b) Track = +150");
                        Console.WriteLine("For TWO WAY: ");
                        Console.WriteLine("(a) Wheel = +40");
                        Console.WriteLine("(b) Track = +30");
                        Console.ReadLine();
                    }
                }
            }

        }
    }
}
below isexcel table i will be using, there are almost 50 more, so i want to use the easiest methpd to complete my program. THe code above shows how i just give these conditions and manually generate line using Write.Line syntex. .please help me out. i am using Visual studio 2012. its a mathematical program.I am stuck . please help.this table is iin.Xlsx
                            (a) 6" slab								
SPAN (ft)	20FT ROADWAY			40FT ROADWAY			
	ONE WAY		TWO WAY		ONE WAY		TWO WAY	
	 W	 T	 W	T	W	T	 W	  T
5	150	150	40	30	150	150	150	120
5.5	96	150	40	30	96	150	65	120
6	75	150	40	30	75	150	53	120
7	54	150	35	30	54	150	37	100
8	38	95	24	30	38	95	24	45
9	27	57	19	23	27	57	19	22
10	21	37	15	17	21	37	15	17
11	17	23	12	14	17	23	12	14
12	15	18	10	11	15	18	10	10
13	13	15	9	8	13	15	9	7
14	11	12	8	6	11	12	7	6
15	9	8	6	5	9	8	6	5
16	7	6	4	4	7	6	4	4



Viewing all articles
Browse latest Browse all 21115

Trending Articles



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