Skip to content

Instantly share code, notes, and snippets.

@dejibimbolaAyo
Last active May 26, 2016 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dejibimbolaAyo/0943f9363c25f4e1fdb09f84d97a4c83 to your computer and use it in GitHub Desktop.
Save dejibimbolaAyo/0943f9363c25f4e1fdb09f84d97a4c83 to your computer and use it in GitHub Desktop.
class and take home assignments
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace add_with_method_add
{
class Program
{
static void Main(string[] args)
{
double var1, var2;
double added;
var1 = Convert.ToDouble(Console.ReadLine());
var2 = Convert.ToDouble(Console.ReadLine());
added = myAdd.addSum(var1, var2);
Console.WriteLine(added);
Console.ReadLine();
}
}
}
class myAdd
{
public static double addSum(double a, double b)
{
return a + b;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace printOut
{
class printer
{
public void Write(string stringA)
{
Console.WriteLine("===== {0} =====", stringA);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace display_random
{
class Program
{
static void Main(string[] args)
{
double myRand;
List<double> myList = new List<double>();
Random randomGenerate = new Random();
for (int i = 0; i < 10000; i++)
{
myRand = 10000 * randomGenerate.NextDouble() + 1;
myList.Add(myRand);
foreach(int num in myList)
{
Console.WriteLine("{0} ", num);
string num2 = Convert.ToString(num);
File.AppendAllText("../random.txt", num2);
};
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace quadratic_eqn
{
class Program
{
static void Main(string[] args)
{
double a;
double b;
double c;
double square_b;
double neg_b;
double two_a;
double neg_four_a_c;
double square_b_minus_4ac;
double root_of_square_b_4ac;
double upper_calc_one;
double upper_calc_two;
double x_one;
double x_two;
a = Convert.ToDouble(Console.ReadLine());
b = Convert.ToDouble(Console.ReadLine());
c = Convert.ToDouble(Console.ReadLine());
square_b = b * b;
neg_b = b * (-1);
two_a = 2 * a;
neg_four_a_c = 4 * a * c * (-1);
square_b_minus_4ac = square_b - neg_four_a_c;
if (square_b_minus_4ac < 0)
Console.WriteLine(" quadratic equation has no solution");
else
{
root_of_square_b_4ac = Math.Sqrt(square_b_minus_4ac);
upper_calc_one = neg_b + root_of_square_b_4ac;
upper_calc_two = neg_b - root_of_square_b_4ac;
x_one = upper_calc_one / two_a;
x_two = upper_calc_two / two_a;
Console.WriteLine("x1= {0}", x_one);
Console.WriteLine("x2= {0}", x_two);
Console.ReadLine();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test_for_divisibility_248
{
class Program
{
static void Main(string[] args)
{
double test0 = 0;
double test =0;
Console.WriteLine("input number to be tested");
test0 = Convert.ToDouble(Console.ReadLine());
if (test0 == 0)
Console.WriteLine("number not divisible by 8");
if (test0 >= 8 && test0 != 0)
test = test0 % 8;
if (test == 0)
Console.WriteLine("number divisible by 8");
else
Console.WriteLine("number not divisible by 8");
//Console.WriteLine(test);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test_pass_or_fail
{
class Program
{
static void Main(string[] args)
{
int accumulate = 0;
int score;
int for_loop = 0;
for (for_loop=0; for_loop<10; for_loop++)
{
accumulate = Convert.ToInt32(Console.ReadLine());
score = score + accumulate;
}
if (score >= 70)
Console.WriteLine("student passed");
else
Console.WriteLine("student failed");
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment