CS2350/01
Programming Languages
|
Course
Syllabus
|
Textbook and Resources
C#
Programming: From Problem Analysis to Program Design, by Barbara Doyle, Second Edition, ISBN 13:
978-1-4239-0146-4 © 2008, ISBN 10: 1-4239-0146-0, Publish date: August 21,
2007 Publisher: Thomson Course Technology |
Instructor
Dr. Yong Shi Office: Phone:
(770)423-6423 Email: yshi5@kennesaw.edu |
|
Recursive Functions Hanoi in C# |
|
Exam 1 |
|
|
|
Lab 1 Write a set of * characters based on the user
input so that they form a square
(the user specifies the side length),
a rectangle (the user specifies
the width and height), and a triangle
(the user specifies the side length of the bottom line, and the height).
Preparation: 1. How to read an integer from
the user input? (check out class Convert and class Int32) 2. How to do a for loop in C#? 3. How to do if-else in C#? Lab 2 Follow the menu style in Sample2 of lab1
The user should be able to try each one as many
times as they want Due: 11:59 09/04/2009 Lab 3
For example, when user inputs 4, your program should output Thursday Due: 11:59 09/11/2009 Lab 4 Follow the menu style in Sample2 of lab1 The user should be able to try each one as many
times as they want 1. Write a program to
output max and min of the input (a group of data, either integers or doubles) 2. Write a program to calculate
the circumference of a circle. Declare a named constant for pi with a value
of 3.14159. Display the result with 3 digits on the right side of the decimal
point. 3. Write a program to print the maximum numbers of quarters, dimes, nickels, and
pennies that a customer should get back as change. This program will first
read the amount of cents for the value to be converted. For example, if the user
inputs 34 as the amount of cents, your programs
should output 1 quarter, 1 nickel, and 4 pennies. 4. Write a program to determine
which way is most economic to purchase the carpets. Suppose the customer
wants to purchase carpets for 3 bed rooms, 1 living room, and 1 sun room. The
sizes of the rooms are provided by the customer in feet and inches (For
example: length: 12 feet 3 inches, width: 14 feet 4 inches). There
are two carpet options: Berber
(best) @ $27.95 per square yard Pile
(economy) @ 15.95 per square yard And
customer wants to use Berber
for 2 of the 5 rooms, and Pile for 3 of the 5 rooms. Due: 11:59 09/18/2009 Lab 5 Follow the menu style in Sample2 of lab1 Preparation: 1. check out the ArrayList class in C# (google
c# arraylist class) http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx 2. how to convert from Object to
Double? Or from Object to Integer? 3. how to measure how many
digits an integer has? Write a program to: 1.
output the ordered list of the input (with duplicate values,
either integers, or doubles) 2. output the median of the input (a group of integers) Definition: a) Median: the number(s) in the middle of the ordered list. b)
If there are odd number of input numbers, the median is the middle number
(For example, if the input is: 3 4
5 1 2, the median is 3)
c) If there are even number of input numbers, the median is the average
of the middle two numbers
(For example, if the input is: 3 4 5 1 2 6, the median is
(3+4)/2 which is 3.5) 3. calculate the cubes of int values up to 100. The output should be in two columns:
the first lists the value; the second contains the cube of that value. Manage
the output so that the values line up in columns. (check out int_variable.ToString().Length if int_variable is an integer variable) Due: 11:59 09/25/2009 Lab 6 Follow the menu style in Sample2 of lab1 Preparation: 1. check out struct
in C# (google c# struct) (http://msdn.microsoft.com/en-us/library/ah19swz4(VS.71).aspx) What are the differences between structs and
classes? Why do we need to use structs sometimes? 2. check out the List class in
C# (google c# list class) (http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx) Pay close attention to: a) How a List object is defined
and instantiated b) How the elements are inserted
into a List c) How the elements are sorted
in a List (Different sort methods of List) 3. how to compare two strings? Write a program to: 1. Given a number n, try to
calculate the sum from 0 to n in both recursive and non-recursive way 2. Define a struct
for each student which records his/her first name, last name, and ksu id. Read
from the user student information, and add them into a List Output
the student information sorted by their ksu ids Output
the student information sorted by their last names Output
the student information sorted by their first names. Due: 11:59 10/2/2009 Lab 7 Follow the menu style in Sample2 of lab1 Imagine a course in
which the final exam counts for 40% of the final grade, the midterm exam
counts for 40%, and the median homework grade makes up the remaining 20%. The
student will get
A (90 to 100)
B (80 to 89)
C (70 to 79)
D (60 to 69)
F (59 or below) Write a program to: 1.
Define a class for each student which records his/her ksu id, first name, last name, midterm grade, final
grade, and (multiple) homework grades. Try different modifiers (static,
public, private, etc) to see how they work. Write methods such as:
CalculateGrade()
GetKsuId()
GetFirstName()
GetLastName() 2.
Read from the user student information, and add them into a List. 3.
Make sure that no two students have the same ksu
id 4.
Output the student ksu id, firstname, last name, and the course grade (A, B, C, D,
or F) sorted by a) their ksu
ids b) their first names c) their last names Due: 11:59 10/9/2009
An example of output: Please input your student information: KSU Id: 1234 First Name: Mary Last Name: Jane Midterm: 90 Final: 80 homework: 100 homework: 80 homework: 70 homework: 80 homework: More students? (y/n) y KSU Id: 2345 First Name: Peter Last Name: Pan Midterm: 90 Final: 80 homework: 70 homework: 80 homework: 80 homework: 80 homework: 90 homework: More students? (y/n) y KSU Id: 3456 First Name: John Last Name: Smith Midterm: 100 Final: 100 homework: 90 homework: 80 homework: 70 homework: 90 homework: 60 homework: 70 homework: More students? (y/n) y KSU Id: 3456 KSU Id already exists in the system,
please input a new one: 1234 KSU Id already exists in the system,
please input a new one: 2345 KSU Id already exists in the system,
please input a new one: 4567 First Name: James Last Name: Brown Midterm: 80 Final: 80 homework: 70 homework: 50 homework: 60 homework: More students? (y/n) n Sorted by KsuId: KSU id: 1234 Name: Mary Jane Grade: B KSU id: 2345 Name: Peter Pan Grade: B KSU id: 3456 Name: John Smith
Grade: A KSU id: 4567 Name: James Brown Grade: C Sorted by First Name: KSU id: 4567 Name: James Brown Grade: C KSU id: 3456 Name: John Smith
Grade: A KSU id: 1234 Name: Mary Jane Grade: B KSU id: 2345 Name: Peter Pan Grade: B Sorted by Last Name; KSU id: 4567 Name: James Brown Grade: C KSU id: 1234 Name: Mary Jane Grade: B KSU id: 2345 Name: Peter Pan Grade: B KSU id: 3456 Name: John Smith
Grade: A Press any key to continue . . . Lab 8 Follow the menu style in Sample2 of lab1 Due: 11:59 10/16/2009 Imagine for each
course, the final exam counts for 40% of the final grade, the midterm exam
counts for 40%, and the median homework grade makes up the remaining 20%. The
student will get grade points for each course:
4 (90 to 100)
3 (80 to 89)
2 (70 to 79)
1 (60 to 69)
0 (59 or below) Write a program to: 1.
Define a struct CourseInfo
to record the name and credit hours for each course 2.
Ask the user to input all the course information (course name and
credit hours) 3.
Ask the user to input information for each student including KSU id,
first name, last name, and for each course, its midterm, final, and homework
grades. For each student, for each course, the grade points are calculated as
mentioned above. For each student, calculate the grade point average (GPA) by
dividing the total amount of grade points earned by the total amount of
credit hours attempted. 4.
Make sure that no two students have the same ksu
id 5.
Output the student ksu id, firstname, last name, and GPA sorted by a) their ksu
ids b) their first names c) their last names
An example of output: Please input course information,
ending with enter key Course name: Biology Course credit:3 Course name: Biology Lab Course credit:1 Course name: English 101 Course credit:3 Course name: Mathematics Course credit:3 Course name: Please input your student
information: KSU Id: 1234 First Name: Mary Last Name: Joe Please input the grades for course
Biology: Midterm: 60 Final: 60 homework: 60 homework: 60 homework: 60 homework: Please input the grades for course
Biology Lab: Midterm: 70 Final: 70 homework: 70 homework: 70 homework: 70 homework: 70 homework: Please input the grades for course
English 101: Midterm: 80 Final: 80 homework: 80 homework: 80 homework: 80 homework: Please input the grades for course
Mathematics: Midterm: 90 Final: 90 homework: 90 homework: 90 homework: More students? (y/n) y KSU Id: 2345 First Name: Peter Last Name: Pan Please input the grades for course
Biology: Midterm: 60 Final: 60 homework: 60 homework: 60 homework: 60 homework: Please input the grades for course
Biology Lab: Midterm: 70 Final: 70 homework: 70 homework: 70 homework: 70 homework: Please input the grades for course
English 101: Midterm: 60 Final: 60 homework: 60 homework: 60 homework: Please input the grades for course
Mathematics: Midterm: 70 Final: 70 homework: 70 homework: 70 homework: 70 homework: More students? (y/n) y KSU Id: 2345 KSU Id already exists in the system,
please input a new one: 3456 First Name: John Last Name: Smith Please input the grades for course
Biology: Midterm: 90 Final: 90 homework: 90 homework: 90 homework: 90 homework: Please input the grades for course
Biology Lab: Midterm: 100 Final: 100 homework: 90 homework: 90 homework: 90 homework: Please input the grades for course
English 101: Midterm: 90 Final: 90 homework: 90 homework: 100 homework: 90 homework: Please input the grades for course
Mathematics: Midterm: 90 Final: 90 homework: 90 homework: 90 homework: 90 homework: 90 homework: 90 homework: More students? (y/n) n Sorted by KsuId: KSU id: 1234 Name: Mary Joe
GPA: 2.6 KSU id: 2345 Name: Peter Pan
GPA: 1.4 KSU id: 3456 Name: John Smith
GPA: 4.0 Sorted First Name: KSU id: 3456 Name: John Smith
GPA: 4.0 KSU id: 1234 Name: Mary Joe
GPA: 2.6 KSU id: 2345 Name: Peter Pan
GPA: 1.4 Sorted by Last Name; KSU id: 1234 Name: Mary Joe
GPA: 2.6 KSU id: 2345 Name: Peter Pan
GPA: 1.4 KSU id: 3456 Name: John Smith
GPA: 4.0 Press any key to continue . . . Lab 9 Due: 11:59 10/23/2009 Purpose of the lab:
get familiar with working with files using classes such as StreamReader and StreamWriter Imagine for each course,
the final exam counts for 40% of the final grade, the midterm exam counts for
40%, and the median homework grade makes up the remaining 20%. The student
will get grade points for each course:
4 (90 to 100)
3 (80 to 89)
2 (70 to 79)
1 (60 to 69)
0 (59 or below) Write a program to: 1. Define a struct CourseInfo to record the
name and credit hours for each course 2. Ask the user to input all the course information (course name and
credit hours) 3. Ask the user to input information for each student including KSU id,
first name, last name, and for each course, its midterm, final, and homework
grades. For each student, for each course, the grade points are calculated as
mentioned above. For each student, calculate the grade point average (GPA) by
dividing the total amount of grade points earned by the total amount of
credit hours attempted. 4. Make sure that no two students have the same ksu
id
5. Output the student ksu id, firstname, last name, and GPA sorted by a) their ksu
ids b) their first names c) their last names 6.
Write the course information (the name and credit hours for each course) to a
file
7. Write the student information (ksuID,
first name, last name, and midterm, final and homework grades
for each course) to another file
(files for 6 and 7 are different)
clear up all your lists (including student list, course list, homework
list etc)
8. Read the course information from a file
9. Read the student information from another file
(files for 8 and 9 are different)
10. Output the student ksu id, firstname, last name, and GPA sorted by d) their ksu
ids e) their first names f) their last names
An example of output: Please input course information, end
with enter key Course name:English Course credit:3 Course name:Math Course credit:3 Course name:Programming Course credit:4 Course name: Please input your student
information: KSU Id: 0003234235 First Name: John Last Name: Smith Please input the grades for course
English: Midterm: 90 Final: 90 homework: 90 homework: 90 homework: 90 homework: Please input the grades for course
Math: Midterm: 89 Final: 89 homework: 89 homework: 89 homework: 89 homework: 89 homework: Please input the grades for course
Programming: Midterm: 80 Final: 80 homework: 80 homework: 80 homework: 80 homework: 80 homework: 60 homework: More students? (y/n) y KSU Id: 000343241 First Name: Mary Last Name: Jones Please input the grades for course
English: Midterm: 80 Final: 80 homework: 80 homework: 80 homework: Please input the grades for course
Math: Midterm: 60 Final: 60 homework: 60 homework: 60 homework: 90 homework: Please input the grades for course
Programming: Midterm: 80 Final: 80 homework: 90 homework: 90 homework: 90 homework: 90 homework: 90 homework: 90 homework: More students? (y/n) n Sorted by KsuId: KSU id: 343241 Name: Mary Jones
Grade: 2.4 KSU id: 3234235 Name: John Smith
Grade: 3.3 Sorted First Name: KSU id: 3234235 Name: John Smith
Grade: 3.3 KSU id: 343241 Name: Mary Jones
Grade: 2.4 Sorted by Last Name; KSU id: 343241 Name: Mary Jones
Grade: 2.4 KSU id: 3234235 Name: John Smith
Grade: 3.3 ************************************************************************** Write Course Information and Student
Information to files What would be the course information
file name: courseInfo.txt What would be the student information
file name: studentInfo.txt Writing process is successful¡ ************************************************************************** ************************************************************************** Read Course Information and Student
Information from files What would be the course information
file name: courseInfo.txt What would be the student information
file name: studentInfo.txt Reading process is successful¡ ************************************************************************** Sorted by KsuId: KSU id: 343241 Name: Mary Jones
Grade: 2.4 KSU id: 3234235 Name: John Smith
Grade: 3.3 Sorted First Name: KSU id: 3234235 Name: John Smith
Grade: 3.3 KSU id: 343241 Name: Mary Jones
Grade: 2.4 Sorted by Last Name; KSU id: 343241 Name: Mary Jones
Grade: 2.4 KSU id: 3234235 Name: John Smith
Grade: 3.3 Press any key to continue . . . Lab 10 Follow the menu style in Sample2 of lab1 Due: 11:59 10/30/2009
1. Write a program that generates 100 random numbers between 0 and
1000. Display the number of even
values generated as well as the smallest, the largest, and the range
of values. Output should be
displayed in a Windows messagebox.
You can look at the Random class in C#.
For example, in your messagebox,
there will be: Even numbers: 54 Smallest number: 0 Largest number:
993 Range of numbers: 0 - 993
2. Prompt the user for the length of three line segments as integers.
If the three lines could form a
triangle, print the integers and a message indicating they form a
triangle. Recall that the sum of
the lengths of any two sides must be greater than the length of the
third side to form a triangle.
For example, 20, 5, and 10 cannot be the lengths of the sides of a
triangle because 5 + 10 is not
greater than 20. For line segments that do not form a triangle, print
the integers and an
appropriate message indicating no triangle can be created. Use a
state-controlled loop to allow
users to enter as many different combinations as they want. For example: *** You can be prompted to enter 3 integers which could
possibly *** be the respective lengths of the three sides of a
triangle. Please enter the first integer: 20 Please enter the second integer: 1 Please enter the third integer: 3 * The
numbers 20 , 1, and 3 CANNOT represent sides of the same triangle. * Would you like to try 3 numbers? Please enter
'y' for yes or another letter for no: y Please enter the first integer: 10 Please enter the second integer: 6 Please enter the third integer: 8 * The numbers 10
, 6, and 8 CAN represent sides of the same triangle. * Would you like to try 3 numbers? Please enter
'y' for yes or another letter for no: n
3. Write a program that produces a multiplication table. Allow the
user to input the first and last
base values for the multiplication table. Display a column in the
table beginning with the first
base inputted value. The last column should be the ending base value
entered. Produce 15 rows of
computations. The first row should be for 1 times the beginning base,
1 times the (beginning base
value + 1), through 1 times the ending base value. The last row should
be for 15 times the
beginning base, 15 times the (beginning base value + 1), through 15
times the ending base value.
Base values can range from 2 through 8. Display a formatted
multiplication table. For example: *** You
will be prompted to enter two integers. *** *** A
multiplication table will be displayed *** ***
based on these two base values entered.
*** *** Base
values multiplied from 1 through 15. *** ***
Enter as many sets of 2 bases as you like. *** Please enter the first base value, 2 - 8 : 2 Please enter the last base value <= 8 : 5
X
2
3
4
5
1
2
3
4
5
2
4
6
8
10
3
6
9
12
15
4
8
12
16
20
5
10
15
20
25
6
12
18
24
30
7
14
21
28
35
8
16
24
32
40
9
18
27
36
45
10
20
30
40
50
11 22 33 44 55
12
24
36
48
60
13
26
39
52
65
14
28
42
56
70
15
30
45
60
75 ***
Would you like to enter two base values? *** Please
enter 'y' for yes or any other letter for no: n Lab 11 Follow the menu style in Sample2 of lab1 Due: 11:59 11/13/2009
Write a program to 1. read the information of
multiple groups of students. Each group may contain different number of students.
For each group, output the median GPA and average GPA. Define a class of Student
which contains information such as first name, last name, GPA, etc. Define a jagged
array of Student class objects. An example to create a jagged array: int[ ] [ ] anArray = new int[4] [ ]; anArray [0] = new int[2]; anArray[0][0] = 100; anArray[0][1]
= 200; anArray [1] = new int[ ] {11, 22,
37}; anArray [2] = new int[ ] {16, 72,
83, 99, 106}; anArray [3] = new int[ ] {1, 2,
3, 4}; An example of output: How many groups of students would you
like to input: 3 How many students would you like to
input for group 1: 3 Group 1 student 1 first name: Mary Group 1 student 1 last name: Joe Group 1 student 1 GPA: 3.4 Group 1 student 2 first name: Peter Group 1 student 2 last name: Pan Group 1 student 2 GPA: 2.3 Group 1 student 3 first name: John Group 1 student 3 last name: Smith Group 1 student 3 GPA: 4.0 How many students would you like to
input for group 2: 2 Group 2 student 1 first name: Tom Group 2 student 1 last name: Hanks Group 2 student 1 GPA: 3.3 Group 2 student 2 first name: Tom Group 2 student 2 last name: Cruise Group 2 student 2 GPA: 3.2 How many students would you like to
input for group 3: 4 Group 3 student 1 first name: Lucy Group 3 student 1 last name: Liu Group 3 student 1 GPA: 4.0 Group 3 student 2 first name: Pete Group 3 student 2 last name: Samprass Group 3 student 2 GPA: 4.0 Group 3 student 3 first name: Roger Group 3 student 3 last name: Federer Group 3 student 3 GPA: 3.9 Group 3 student 4 first name: Rafa Group 3 student 4 last name: Nadal Group 3 student 4 GPA: 3.8 Median GPA for group 1 is 3.4, and
average GPA for group 1 is 3.23 Median GPA for group 2 is 3.25, and
average GPA for group 2 is 3.25 Median GPA for group 3 is 3.95, and
average GPA for group 3 is 3.93 Press any key to continue . . . 2. create a two-dimensional array
with 10 rows and 2 columns. The first column should be filled with 10 random
numbers between 0 and 100. The second column should contain the squared value
of the element found in column 1. Using the Show() method of the MessageBox class, display a table. Lab 12 Due: 11:59 11/20/2009
Write a window based student information inputting system. The user
can input KSU id, first name, last name and GPA for each student.
Each time the user clicks the Save button,
the information of the current student will be saved into system, and all the
textboxes will be cleared to get ready for the information of the next
student. When the user are done with inputting, the
user can click the Recording finished button. Then more buttons will
show up:
The user can then view the student information ordered by different
features by clicking on different buttons. Each time the user clicks a
button, a messagebox will pop up to show the
student information. For example, if the user clicks Students ordered by ksu id button, the following messagebox
will pop up:
The system also need to check if the new coming ksu
id is already in the system, if so, a messagebox
will pop up to notify the user, and the textbox for ksuid
will be cleared for the user to re-input ksuid
(other textboxes should not be cleared). |
|
|
|
NOTICE: the submission email is yshi04@gmail.com |
|
|
|
|