lecture5-OOP1200024170.pdf
Assignment2
연습문제 Ex2 (Due by 9/24 목 24시까지)1307735758.hwp
-cyber 강의실 (cyber.dku.edu)로 source code, executable file, solution/project VC# file, 보고서를 학번_이름_Ex2.zip으로 묶어서 낼 것. 보고서 (30%)
[연습문제]
1. Ex1 (학생 학점을 출력하는 프로그램인 StudentGrade 클래스 숙제)에 Student 구조체를 사용하여 다시 작성하라 (그리고, Student.cs 파일로 저장한다). Student 구조체에는 학생 이름(name), 국어(kor), 영어(eng), 수학(math), 학점(grade)이 데이터 멤버로 포함되어야 한다. (30%)
– Student(string n, int k, int e, int m) 생성자
– int GetTotal() 함수는 국어, 영어, 수학의 총점 값을 반환 (Ex1과 동일)
– int GetAverage() 함수는 국어, 영어, 수학의 평균 값을 반환 (Ex1과 동일)
– Grade GetGrade() 함수는 학생 성적평균이 90이상이면 A, 80-90이면 B, 70-80이면 C, 60-70이면 D, 60이하 F인 enum type인 Grade 값을 반환 (Ex1과 동일)
– PrintGrade() 함수는 학생의 이름과 국어, 영어, 수학 성적 및 총점, 평균, 학점을 화면에 출력
2. Main 함수에서는 10개의 Student 구조체를 Array로 생성하고 키보드 입력으로 학생 이름, 국어, 영어, 수학 점수를 받아서, 각 학생별로 총점, 평균, 학점을 출력하고, 전체 학생에 대한 평균 총점, 평균을 출력하는 routine을 추가한다. (20%)
– for 문을 사용하여 10명 학생의 이름, 국어, 영어, 수학 점수를 입력받음
– foreach 문을 사용하여 10명 학생에 대한 개별적인 성적 출력과 전체 학생의 평균 총점및 평균을 계산 후 출력
3. Main 함수에서 본인이 더 테스트해보고 싶은 Method나 routine을 추가하라. (20%)
Statement & Method
Break Statement vs. Continue Statement
1075903897.cs
Recursive Method
1306158747.cs
디버그모드에서 윈도우창을 계속 열기위한 방법
Visual Studio 2008에서 F5(Debug) 실행시 윈도우 창을 계속 열기 위한 방법
// Keep the console window open in debug mode.
Console.WriteLine(“Press any key to exit.”);
Console.ReadKey();
Array & Struct
Array1220407129.cs
Struct1267020452.cs
Operator
Arithmetic Operator1288618202.cs
Temperature Converter1336130967.cs
DataType
Boolean (bool)
1100942857.cs
Character (char)
1155938361.cs
Enumeration (enum)
1028714810.cs
Numeric (int, long, float, double, decimal, etc)
1104654313.cs
String1157964094.cs
Object1196044571.cs
Build.bat 1165214317.xxx
HelloWorld
HelloWorld 예제
// Hello1.cs
public class Hello1
{
public static void Main()
{
System.Console.WriteLine(“Hello, World!”);
}
}
// Hello2.cs – using System을 사용
using System;
public class Hello2
{
public static void Main()
{
Console.WriteLine(“Hello, World!”);
}
}
// Hello3.cs – program argument 를 처리
// arguments: A B C D
using System;
public class Hello3
{
public static void Main(string[] args)
{
Console.WriteLine(“Hello, World!”);
Console.WriteLine(“You entered the following {0} command line arguments:”,
args.Length );
for (int i=0; i < args.Length; i++)
{
Console.WriteLine(“{0}”, args[i]);
}
}
}
// Hello4.cs – Main 메소드에 반환인자를 넣을 경우
using System;
public class Hello4
{
public static int Main(string[] args)
{
Console.WriteLine(“Hello, World!”);
return 0;
}
}
lecture4 – C# Basics
lecture4 – C# Basics
Methods, Variables, Array1141554847.pdf
Assignment1
Assignment1 (Due by 9/17 목 24시까지)
1183755079.hwp
참고: VC# .NET2008을 사용하여 Console Application으로 작성한다.
http://dis.dankook.ac.kr/lectures/hci09/6
연습문제 Ex1 (Due by 9/17 목 24시까지)
-cyber 강의실 (cyber.dku.edu)로 source code, executable file, solution/project VC# file, 보고서를 학번_이름_Ex1.zip으로 묶어서 낼 것. 보고서 (30%)
[연습문제]
1. 학생 학점을 출력하는 프로그램인 StudentGrade 클래스를 작성하라. 학생 이름(name), 국어(kor), 영어(eng), 수학(math), 학점(grade)이 데이터 멤버로 포함되어야 한다. (30%)
– enum Grade { A, B, C, D, F };를 사용
– int GetTotal() 함수는 국어, 영어, 수학의 총점 값을 반환
– int GetAverage() 함수는 국어, 영어, 수학의 평균 값을 반환
– Grade GetGrade() 함수는 학생 성적평균이 90이상이면 A, 80-90이면 B, 70-80이면 C,
60-70이면 D, 60이하 F인 enum type인 Grade 값을 반환
– PrintGrade() 함수는 학생의 성적 총점, 평균, 학점을 화면에 출력
2. Main 함수에서는 StudentGrade s 객체를 생성하고 키보드 입력으로 학생 이름, 국어, 영어, 수학 점수을 받아서, 총점, 평균, 학점을 출력하는 routine을 추가한다. (20%)
– 국어, 영어, 수학 점수는 0-100 사이의 integer 값만을 입력받도록 해야 함
– 힌트: while 문을 사용하여 국어, 영어, 수학 점수가 0-100사이의 integer가 아닌 경우
다시 입력을 받음
– 힌트: Console.ReadLine() 함수는 string을 반환하므로, int로 변환하기 위하여 Parse
함수 사용 => intValue = int.Parse(string)
– 힌트: TryParse 함수는 string을 integer로 변환이 가능하면, out 매개변수로 변환된
값을 전달해 주고, true boolean 값을 반환
=> boolValue = int.TryParse(string, out intValue)
3. Main 함수에서 본인이 더 테스트해보고 싶은 StudentGrade 클래스의 Method나 routine을 추가하라. (20%)