You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System;classProgram{staticvoidMain(){/*** loop through numbers 1-100 and use the modulo operator to find mulpitles of any number, in this case, 3 and 5. ***/for(inti=1;i <= 100;i++){stringloop="";if(i%3==0){loop+="Explorica";}if(i%5==0){loop+="Tours";}if(loop.Length ==0){loop= i.ToString();}
Console.WriteLine(loop);}}}
Question Two
using System;namespaceWSQuestions{classTriangles{publicvoidDrawTop(){introw;intcolumn;intspace;/*** first 6 lines of diamond- will add a star for every column <= (2 * row) - 1, where row will increment***/for(row=1;row <= 6;row++){for(space=6;space>row;space--)
Console.Write("");for(column=1;column <= (2*row)-1;column++)
Console.Write("*");
Console.WriteLine();}}/*** last 5 lines of diamond- will add a star for every column <= (2 * row) - 1, where row will decrement ***/publicvoidDrawBottom(){introw;intcolumn;intspace;for(row=5;row >= 1;row--){for(space=6;space>row;space--)
Console.Write("");for(column=1;column <= (2*row)-1;column++)
Console.Write("*");
Console.WriteLine();}}}classProgram{staticvoidMain(){Trianglesapp=new Triangles();//first pattern
app.DrawTop();//second pattern
app.DrawTop();
app.DrawBottom();}}}
Question Three
Given a File "text.txt":
2
##
######
####
#
######
#######
###
Where N = 2. Find the minimum and maximum lengths of N joined together.
using System;using System.IO;using System.Linq;namespaceWSQuestions{classProgram{staticvoidMain(string[]args){// Read in the file inputstring[]textFile= File.ReadAllLines("text.txt");// Skip the first line of the input filetextFile= textFile.Skip(1).ToArray();//initialize variablesstringfirstMinVal= textFile[0];stringsecondMinVal="";stringfirstMaxVal= textFile[0];stringsecondMaxVal="";/*** Iterate over strings in file- first traversal finds minimum, second scan finds smallest length greater than the minimum ***/foreach(string text in textFile){
Console.WriteLine(text.Length);if(text.Length < firstMinVal.Length){secondMinVal=firstMinVal;firstMinVal=text;}/*** Iterate over strings in file- first traversal finds maximum, second scan finds largest length greater than the maximum***/if(text.Length > firstMaxVal.Length){secondMaxVal=firstMaxVal;firstMaxVal=text;}}// Join the minimums and maximums for final calculationintfinalMinVal= firstMinVal.Length + secondMinVal.Length;intfinalMaxVal= firstMaxVal.Length + secondMaxVal.Length;// Write results
Console.WriteLine("Result: "+"\r\n"+"Min: "+finalMinVal+" | Max: "+finalMaxVal);
Console.ReadLine();}}}