티스토리 뷰
Remote Desktop Connection
192.168.31.202
ID : Administrator
PW : P@ssw0rd
Eg. for loop
string completestring = "";
string[] parts = new string[3];
parts[0] = "hello, ";
parts[1] = "hello again, ";
parts[2] = "hello forever";
for (int i = 0; i < parts.Length; i++)
{
completestring = completestring + parts[i];
}
Console.WriteLine(completestring);
Console.ReadLine();
Eg. while loop
int total = 0;
int count = 0;
int currentnumber = 1;
while (currentnumber !=0)
{
//Loop will exit when user enter 0.
Console.WriteLine("Type a decimal number : ");
currentnumber = Convert.ToInt32(Console.ReadLine());
total = total + currentnumber;
count++;
//Console.WriteLine(total);
Console.WriteLine();
}
count--;
double average = total / count;
Console.WriteLine();
Console.WriteLine("Average is " + average);
Console.ReadLine();
eg. do while
int total = 0;
int count = 0;
int currentnumber = 0;
do
{
Console.WriteLine("Type a number : ");
currentnumber = Convert.ToInt32(Console.ReadLine());
total = total + currentnumber;
count++;
}
while (currentnumber != 0);
count--;
double average = 0;
average = total / count;
Console.WriteLine("The average is " + average);
Console.ReadLine();
eg. Woongyeol_choi_P453075_swap_name
// Woongyeol_choi
// P453075
// 11/08/2017
// Woongyeol_choi_P453075_swap_name
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
string personone = "chris";
string persontwo = "john";
string tempstring = "";
Console.WriteLine("First person : " + personone);
Console.WriteLine("2nd person : " + persontwo);
tempstring = personone;
personone = persontwo;
persontwo = tempstring;
Console.WriteLine("First person : " + personone);
Console.WriteLine("2nd person : " + persontwo);
Console.ReadLine();
}
}
}
eg. Woongyeol_choi_p453075_is_chris
// Woongyeol_choi
// P453075
// 11/08/2017
// is_chris
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
string ischris, answer;
bool ismale;
Console.WriteLine("please type your name : ");
answer = Convert.ToString(Console.ReadLine());
if(answer == "chris")
{
ismale = true;
}
else
{
ismale = false;
}
if (ismale == true)
{
Console.WriteLine("You are chris");
}
else
{
Console.WriteLine("You are not chris");
}
Console.ReadLine();
}
}
}
eg. lager_10
// Woongyeol_choi
// P453075
// 11/08/2017
// larger_10
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
int num1, num2, num3;
Console.WriteLine("Type num1 : ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type num2 : ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type num3 : ");
num3 = Convert.ToInt32(Console.ReadLine());
if (num1 > 10 && num2 > 10)
{
Console.WriteLine("num1 and num2 is larger than 10");
if (num3>10)
{
Console.WriteLine("num3 is larger than 10");
}
else
{
Console.WriteLine("num3 is smaller than 10");
}
}
Console.ReadLine();
}
}
}
192.168.31.202
ID : Administrator
PW : P@ssw0rd
Eg. for loop
string completestring = "";
string[] parts = new string[3];
parts[0] = "hello, ";
parts[1] = "hello again, ";
parts[2] = "hello forever";
for (int i = 0; i < parts.Length; i++)
{
completestring = completestring + parts[i];
}
Console.WriteLine(completestring);
Console.ReadLine();
Eg. while loop
int total = 0;
int count = 0;
int currentnumber = 1;
while (currentnumber !=0)
{
//Loop will exit when user enter 0.
Console.WriteLine("Type a decimal number : ");
currentnumber = Convert.ToInt32(Console.ReadLine());
total = total + currentnumber;
count++;
//Console.WriteLine(total);
Console.WriteLine();
}
count--;
double average = total / count;
Console.WriteLine();
Console.WriteLine("Average is " + average);
Console.ReadLine();
eg. do while
int total = 0;
int count = 0;
int currentnumber = 0;
do
{
Console.WriteLine("Type a number : ");
currentnumber = Convert.ToInt32(Console.ReadLine());
total = total + currentnumber;
count++;
}
while (currentnumber != 0);
count--;
double average = 0;
average = total / count;
Console.WriteLine("The average is " + average);
Console.ReadLine();
eg. Woongyeol_choi_P453075_swap_name
// Woongyeol_choi
// P453075
// 11/08/2017
// Woongyeol_choi_P453075_swap_name
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
string personone = "chris";
string persontwo = "john";
string tempstring = "";
Console.WriteLine("First person : " + personone);
Console.WriteLine("2nd person : " + persontwo);
tempstring = personone;
personone = persontwo;
persontwo = tempstring;
Console.WriteLine("First person : " + personone);
Console.WriteLine("2nd person : " + persontwo);
Console.ReadLine();
}
}
}
eg. Woongyeol_choi_p453075_is_chris
// Woongyeol_choi
// P453075
// 11/08/2017
// is_chris
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
string ischris, answer;
bool ismale;
Console.WriteLine("please type your name : ");
answer = Convert.ToString(Console.ReadLine());
if(answer == "chris")
{
ismale = true;
}
else
{
ismale = false;
}
if (ismale == true)
{
Console.WriteLine("You are chris");
}
else
{
Console.WriteLine("You are not chris");
}
Console.ReadLine();
}
}
}
eg. lager_10
// Woongyeol_choi
// P453075
// 11/08/2017
// larger_10
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Woongyeol_choi_P453075_csharp
{
class Program
{
static void Main(string[] args)
{
int num1, num2, num3;
Console.WriteLine("Type num1 : ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type num2 : ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Type num3 : ");
num3 = Convert.ToInt32(Console.ReadLine());
if (num1 > 10 && num2 > 10)
{
Console.WriteLine("num1 and num2 is larger than 10");
if (num3>10)
{
Console.WriteLine("num3 is larger than 10");
}
else
{
Console.WriteLine("num3 is smaller than 10");
}
}
Console.ReadLine();
}
}
}
'AU Study > TAFE' 카테고리의 다른 글
CSS borders (0) | 2017.08.17 |
---|---|
W4 Fri afternoon (0) | 2017.08.17 |
W4 thu morning (0) | 2017.08.15 |
W4 thu afternoon (0) | 2017.08.15 |
W4 wed afternoon (0) | 2017.08.09 |
댓글