Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- const int SIZE = 50;
- static void Main(string[] args)
- {
- int index = 0;
- double res = 0;
- string inputString = "";
- Resistor[] resistor = new Resistor[SIZE];
- string enviroment = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "//";
- Write("please enter the file name:");
- string input = Console.ReadLine();
- StreamReader myFile = new StreamReader(enviroment + input);
- inputString = myFile.ReadLine();
- string[] data = inputString.Split();
- double specifcR = double.Parse(data[0]);
- double maxium = double.Parse(data[1]);
- while(myFile.EndOfStream == false)
- {
- inputString = myFile.ReadLine();
- res = double.Parse(inputString);
- resistor[index++] = new Resistor(res, specifcR);
- }
- WriteLine("Res#\tDissipitation\tPassed");
- for (int i = 0; i < index; i++)
- {
- if(resistor[i].GetOhm() < maxium)
- {
- WriteLine($"{i + 1}\t{resistor[i].GetOhm()}\t no");
- }
- else
- {
- WriteLine($"{i + 1}\t{resistor[i].GetOhm()}\t yes");
- }
- }
- ReadLine();
- }
- class Resistor
- {
- private double volts;
- private double restance;
- /// <summary>
- /// constructor
- /// </summary>
- /// <param name="v"></param>
- /// <param name="r"></param>
- public Resistor(double v,double r)
- {
- restance = r;
- volts = v;
- }
- /// <summary>
- /// ohm law
- /// </summary>
- /// <returns></returns>
- public double GetOhm()
- {
- return (volts * volts)/restance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement