ADVANCED TOPIC: More on Digital Electronics (a whirlwind tour) and the basics of a computer
Remember from last time we showed that a basic transistor, invented in 1947, could work as a highspeed switch;
pictorially, the rst transistor:
The schematic equi
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 5 INHERITANCE
Implement the following classes in Java. Write a main class to test your program.
Employee
# Name: String
# Id: integer
+ Employee( )
+Employee(in Id: int, in n: String)
+ setters/getters
+
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 9 FILE INPUT AND OUTPUT
Exercise 1:
Write a java program that will search a text file of strings representing numbers of type int and
will write the largest and the smallest numbers to the screen. The fi
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 8 EXCEPTIONS
A bank manages many customers accounts. Each bank account can be a saving or a checking account.
BankAccount
Bank
 name: String
+ Bank(String name, int size)
+ search(String accNum): boolea
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 10 FILE INPUT/OUTPUT
To implement a system for managing books in a library, we propose the following UML diagram.
Library
 name: String
+ Library(in N: String, in size: int)
+ addBook(in B: Book): Boole
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 11 LINKED LISTS
Write a program, which maintains a linked list of Employees. For each employee you
should store: Name and SSN number. Implement a class Employee with appropriate
methods: setters methods,
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 3 ARRAY OF OBJECTS
The UML diagram of the Store and the Product is represented as follows.
Product
Store
 Location: String
 ArrayProd [ ]: Product
+ Store (s: String, k: int)
+ addProduct ( Product pr
The switch Statement
THE switch STATEMENT:
Provides a convenient way to execute
conditional code when there are many
cases to choose from.
This construct can replace series of ifelseend statements
LOGICAL PROGRAMMING
CONSTRUCTS
SYNTAX:
switch expressio
CS113 Introduction to Computing
for Engineers
Iteration
1
REVIEW FROM LAST LECTURE
2
REVIEW FROM LAST LECTURE
3
REVIEW FROM LAST LECTURE
4
REVIEW FROM LAST LECTURE
5
REVIEW FROM LAST LECTURE
6
CONDITIONAL STATEMENTS APPLIED TO
MATRICES
> A = [ 0.5, 6.0, 
CS113 Introduction to Computing
for Engineers
Logical Operators and Conditional
Statements
1
Programming in Matlab
2
Programming in Matlab
3
Programming in Matlab
4
Programming in Matlab
5
Programming in Matlab
6
Programming in Matlab
7
Programming in Mat
CS113 Introduction to Computing
for Engineers
MATLAB: Script and Function Files
1
MATLAB Script Files
A MATLAB script file (Called an Mfile) is a text (plain
ASCII) file that contains one or more MATLAB
commands and, optionally, comments.
The file is s
CSC 113: Saving Plots and Graphics in Matlab
This document covers the basics of saving a gure created in M ATLAB, so that it may be used in
some other setting, such as a web page, written report, or overhead presentation.
First, lets create a gure. The fo
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 6 INHERITANCE  POLYMORPHISM
Implement the following classes in Java. Write a main class to test your program.
In the main class: display the list of all employees in the organization with their
attribut
Listing 1:
import java.util.Random;
public class dice
cfw_
public static void main(String[] args)
cfw_
int numberOfTwos
= 0;
/ declare and initialize counters
int numberOfSevens = 0;
int numberOfTwelves = 0;
Random rnd = new Random();
for (int i = 0; i <
More on methods and arrays:
Methods are useful for:
 Replacing redundant code; i.e. code used in more than one place
 Abstraction; complex code is placed elsewhere
 Division of labor
 Reuse
 Modularity
Examples:
!
public class Prime
cfw_
!
public sta
Simple input and output
Simple/basic input/output (I/O) in Java can be performed using the Scanner class, e.g.:
import java.util.Scanner;
public class circleArea
cfw_
public static void main(String[] args)
cfw_
/ Calculate the area of a circle
double pi =
Potential Hint for Assignment #3:
!
Note that players in the Nim game can take up to half the number of marbles in the pile, so.
!
As shown below, it is possible to calculate the ideal number of marbles to take by simply using a cast and conditionals.
/*
Review of the modulus operator in Java:
!
Think of the modulus operator as the remainder function.
!
In addition, note that the operator works from right to left, e.g.:
!
!
!
In other words
!
!
!
Consider the following example:
10 % 3 = 1
The value 3 goes
Basic Computer Science and Java Concepts that everyone should understand!
!
!
1. Variables!
a. Variables in Java represent a storage location in the computers memory!
i. Variables can change over time!
ii. Variables have a specic type associated with them
Assignment #3: Due Wednesday, March 11, by 10:00 AM, PST via email.
Write a program to play the game nim, where a computer and a person alternatively
pick marbles from a pile of known size; the player that picks the last marble losses.
The following must
Guesser Game
import java.util.Random;
import java.util.Scanner;
public class JavaApplication1
cfw_
public static void main(String[] args)
cfw_
Random r = new Random();
Scanner console = new Scanner(System.in);
int value = r.nextInt(100) + 1;
int c
CSC 121
Assignment #2: Due Thursday, Feb. 26, at the start of class via email to
wpbcsc121@gmail.com.
Q1. Enhance question #2 (Q2) from assignment one to verify that the
values for both length and width entered by the user are valid numbers,
i.e. are grea
Assignment #1 Due at the start of class on paper.
Q1: Write a program that prints out the area of a rectangle that is three feel long and
two feet high; be sure to include the units.!
A sample run for a rectangle that is 10 feet long by 21 feet wide:!
$
CSC 121 Review for Quiz #1
 Quiz #1 will be held on Thursday, March 5 and lasts up to 45 minutes, if necessary
 The intention is to ensure that everyone is learning the material
 The quiz is worth 20 Extra Credit Points
 That is the quiz cannot hurt y
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 7 INTERFACE AND ABSTRACT CLASSES
An airport charges any airplane lands in it by the following rules:
1. Every adult is charged 2 S.R. for every kilogram they weigh.
2. Every child is charged 0.5 S.R for
C SC 113
H om ew ork 4
Assigned: October 4, 2010
Due: October 12, 2010
1) The purpose of this assignment is to make use of newly learned conditional statements
and for loops in analyzing a matrix of integers. Two text files will be available on the
class
KSU / CCIS / CS DEPARTMENT
CSC113, SPRING 2010
LAB 2 ARRAY OF OBJECTS
Create class Employee including the following:


Members:
o Integer id
o String name
o Double salary
Methods
o public Employee()
o public Employee(int ID, double Salary, String Name)
CSC357S07L4
Slide 1
CSC 357 Lecture Notes Week 4
Unbuffered File I/O
UNIX Files and Directories
CSC357S07L4
I. Relevant reading:
A. Stevens chapters 3 and 4.
B. Skim chapter 2.
Slide 2
CSC357S07L4
II. C and UNIX standards (Stevens Ch 2)
A. Two level