Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
train555555
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { public static int fix(int x, int y) { int Rem; while (y != 0) { Rem = x % y; x = y; y = Rem; } return x; } static void Main(string[] args) { int a1=0, b1=1, c1=0, d1=1; Console.WriteLine("Enter the values for rational numbers:"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("NOTE! *******************************"); Console.WriteLine("TO REFUSE ENTER A NUMBER TYPE IN: {0}","no"); Console.WriteLine("NOTE! *******************************"); Console.WriteLine(); Console.WriteLine(); Console.Write("Enter a number for the deduction form for the first fraction: "); string a_temp = (Console.ReadLine()); if (a_temp == "no") { a1 = 1; } if (a_temp != "no") { a1 = Convert.ToInt32(a_temp); } Console.Write("Enter a number for the denominator of the first fraction: "); string a_temp1 = (Console.ReadLine()); if (a_temp1 == "no") { b1 = 1; } if (a_temp1 != "no") { b1 = Convert.ToInt32(a_temp1); } Console.WriteLine(); Console.Write("Enter a number for the deduction form for the second fraction: "); string a_temp2 = (Console.ReadLine()); if (a_temp2 == "no") { c1 = 1; } if (a_temp2 != "no") { c1 = Convert.ToInt32(a_temp2); } Console.Write("Enter a number for the denominator of the second fraction: "); string a_temp3 = (Console.ReadLine()); if (a_temp3 == "no") { d1 = 1; } if (a_temp3 != "no") { d1 = Convert.ToInt32(a_temp3); } Console.WriteLine(); Console.WriteLine("{0}/{1} is equal to {2}/{3}", a1, b1, a1 / fix(a1, b1), b1 / fix(a1, b1)); Console.WriteLine("{0}/{1} is equal to {2}/{3}", c1, d1, c1 / fix(c1, d1), d1 / fix(c1, d1)); Console.WriteLine(); Console.WriteLine(); int t1, t2, t3, t4; t1 = a1 / fix(a1, b1); t2 = b1 / fix(a1, b1); t3 = c1 / fix(c1, d1); t4 = d1 / fix(c1, d1); my_math std1 = new my_math(t1,t2,t3,t4); std1.show(); Console.ReadLine(); } } class my_math { int w,x,y,z; public static int fix(int x2, int y2) { int Rem; while (y2 != 0) { Rem = x2 % y2; x2 = y2; y2 = Rem; } return x2; } public my_math() { x = 1; y = 0; w = 0; z = 1; } public my_math(int w1,int x1,int y1,int z1) { w = w1; x = x1; y = y1; z = z1; } public void show() { //Addition int temp1, temp2; temp1 = w * z + y * x; temp2 = x * z; //Minus int temp3 = w * z - y * x; //Division int temp4 = w * z; int temp5 = x * y; //Multiplication int temp6 = w * y; //Float double temp7 = Convert.ToDouble(w) / Convert.ToDouble(x); double temp8 = Convert.ToDouble(y) / Convert.ToDouble(z); Console.WriteLine("Addition is: {0}/{1} ",temp1/fix(temp1,temp2),temp2/fix(temp1,temp2)); Console.WriteLine("Minus is: {0}/{1} ", temp3/fix(temp3,temp2), temp2/fix(temp3,temp2)); Console.WriteLine("Devision is: {0}/{1} ", temp4/fix(temp4,temp5), temp5/fix(temp4,temp5)); Console.WriteLine("Multiplication is: {0}/{1} ", temp6/fix(temp6,temp2), temp2/fix(temp6,temp2)); Console.WriteLine("The first fraction in decimal form is: {0}", temp7); Console.WriteLine("The second fraction in decimal form is: {0}", temp8); } } }
run
|
edit
|
history
|
help
-1
Mintra url string replace
decimal to multiple binary
601
English stop words
Sri 19 Sept
sdsadxaxsd
breadbank
Test
TEST 1
test coeur