Greenville MidTerm Grade A

[code language=”csharp”] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static System.Console; /// <summary> /// # # # # # # # # # # # /// # Mark Hesser # /// # Jan 30, 18 # /// # GreenvilleRevenue # /// # # # # # # # # # # […]

Debug Exercises – Fixed

DebugEight1 [code language=”csharp”] // GetData() method accepts order number and quantity // that are used in the Main() method // Price is $3.99 each using System; using static System.Console; class DebugEight1 { static void Main() { int orderNum = 0, quantity = 0; double total; const double PRICE_EACH = 3.99; GetData(ref orderNum, ref quantity); total […]

Debug Exercises

Each of the four files in the CH8 Debug zipped folder has syntax and/or logical errors. In each case, determine the problem, and fix the program. DebugEight1 [code language=”csharp”] // GetData() method accepts order number and quantity // that are used in the Main() method // Price is $3.99 each using System; using static System.Console; […]

MovieTimes Console App

[code language=”csharp”] using System; using static System.Console; /// <summary> /// # # # # # # # # # # # # # /// # Mark Hesser # /// # Jan 25, 18 # /// # Movie Running Time # /// # # # # # # # # # # # # # # […]

Chapter 8 Figures – code samples

Ambiguous Methods [code language=”csharp”] using static System.Console; class AmbiguousMethods { static void Main() { int iNum = 20; double dNum = 4.5; SimpleMethod(iNum, dNum); // calls first version SimpleMethod(dNum, iNum); // calls second version SimpleMethod(iNum, iNum); // error! Call is ambiguous. } private static void SimpleMethod(int i, double d) { WriteLine("Method receives int and double"); […]

ParamsArray

[code language=”csharp”] using System; using static System.Console; namespace ParamsArray { class Program { static void Main(string[] args) { double[] array = { 3, 7, 9, 12, 16 }; Average(7); Average(26, 98); Average(41.5, 77.6, 98.2, 41.2); Average(array); } static void Average(params double[] nums) { double total = 0; double avg; foreach (double number in nums) { […]

MemorySwap

[code language=”csharp”] using System; namespace MemorySwap { class Program { static void Main(string[] args) { int first=24, second=45; Console.WriteLine("The value of first is {0} and second is {1}", first, second); Swap(ref first, ref second); Console.WriteLine("The new value of first is {0} and second is {1}", first, second); } static void Swap(ref int one, ref int […]