code snippet c sharp.docx - Code1 using using using using using System System.Collections.Generic System.Linq System.Text System.Threading.Tasks

code snippet c sharp.docx - Code1 using using using using...

This preview shows page 1 - 5 out of 16 pages.

Code 1:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceassignment_1_aashirbadam{classProgram{staticvoidMain(string[] args){intx;inty;intz = 0;intavg = 0;intremainder = 0;Console.WriteLine(" Enter the Integer ");stringnum1= Console.ReadLine();x = Convert.ToInt32(num1);Console.WriteLine(" Enter the Integer ");stringnum2 = Console.ReadLine();y = Convert.ToInt32(num2);Console.WriteLine(" Enter the Integer x");stringnum3 = Console.ReadLine();z = Convert.ToInt32(num3);avg = (x + y + z) / 3;remainder = (x + y + z) % 3;Console.WriteLine("The avage of "+ x +","+ y + ","+ z + ","+" is "+ avg + " with a remainder of "+ remainder);}}}Code 2:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceassignment_2_aashirbadam{
Background image
classaverage{publicintscope1;publicintscope2;publicintscope3;publicintadd(intscope1, intscope2, intscope3){this.scope1 = scope1;this.scope2 = scope2;this.scope3 = scope3;return((scope1 + scope2 + scope3) / 3);}publicintCalculateAverage(intadd){returnadd;}publicintCalculateRemainder(intadd){returnadd % 3;}publicvoidDisplayAverage(intCalculateAverage, intCalculateRemainder){Console.WriteLine("The average of "+ scope1 + ","+ scope2 + ","+ scope3 + " is"+ " "+ CalculateAverage + " "+ "with a remainder of "+ CalculateRemainder);}}classProgram{staticvoidMain(string[] args){averageAvg = newaverage();inttotalSum = Avg.add(1, 3, 4);inttotalavg = Avg.CalculateAverage(totalSum);intremainder = Avg.CalculateRemainder(totalSum);Avg.DisplayAverage(totalavg, remainder);}}}Code 3:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;
Background image
namespaceassignment_3_aashirbadam{classchangeValue{//Create a class called changeValue that declares 2 integer class variables: value1 and // value2. These should be declared as public and you should not use automatic properties // to declare them. publicintValue1 { get; set; }publicintValue2 { get; set; }publicchangeValue(intval1, intval2){Value1 = val1; //here is the constructor where you code the if statementsValue2 = val2;if(val1 > 5){this.Value1 = val1;}elseif(val1 <= 5){this.Value1 = val1 + val2;}if(val2 < 10){this.Value2 = val2 * val2+5;}elseif(val2 > 10){this.Value2 = val2;}}publicvoidprintit(){//here is the printit method used to print the resultsConsole.WriteLine("The calculated value "+ Value1 * Value2);}}classassignment3{publicstaticvoidMain(string[] args){//declare the local val1 and val2 integer variables
Background image
intval1 = 0;intval2 = 0;//prompt the user for input of two integers//don’t forget to convert from the string input to integerConsole.WriteLine("Enter a intiger value");Stringnum1 = Console.ReadLine();val1 = Int32.Parse(num1 );Console.WriteLine("Enter a intiger value");Stringnum2 = Console.ReadLine();val2 = Int32.Parse(num2);changeValuenumber = newchangeValue(val1, val2);number.printit();//instantiate a changeValue object here//call the object method printit here}}}Code 5:usingSystem;namespaceassignment_4_aashirbadam{classEmployee{publicdoublehours { get; set; }publicdoublewage { get; set; }publicdoubleearning { get; set; }publicvoidsalary(doublehournum, double
Background image
Image of page 5

You've reached the end of your free preview.

Want to read all 16 pages?

  • Spring '11
  • Choirey
  • static void Main, yourarea

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes