Lecture Notes: ESC 101

Similar documents
AIMMS Function Reference - Date Time Related Identifiers

Java Programming Language Mr.Rungrote Phonkam

Lecture 6. Drinking. Nested if. Nested if s reprise. The boolean data type. More complex selection statements: switch. Examples.

Handout 7. Defining Classes part 1. Instance variables and instance methods.

CSC 172 Intermediate Progamming

CMIS 102 Hands-On Lab

Arrays III and Enumerated Types

Functional Programming. Lecture 2: Algebra

76 days Wed 8/24/16 Wed 12/7/16 Daniel Wang,Shreyas Makde,Madhavi Potluri,Roua 2 Requirements analysis 11 days Wed 8/24/16 Wed 9/7/16

INFORMATION TECHNOLOGY SPREADSHEETS. Part 1

Data Types. 9. Types. a collection of values and the definition of one or more operations that can be performed on those values

10/22/2018 Programming Data Structures

Chapter 6 Arrays, Part D 2d Arrays and the Arrays Class

Ohad Barzilay and Oranit Dror

Package RcppBDT. August 29, 2016

CMSC 132, Object-Oriented Programming II Summer Lecture 5:

This report is based on sampled data. Jun 1 Jul 6 Aug 10 Sep 14 Oct 19 Nov 23 Dec 28 Feb 1 Mar 8 Apr 12 May 17 Ju

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

CIMA Certificate BA Interactive Timetable

NORTHWEST. Course Schedule: Through June 2018 MICROSOFT ACCESS. Access 2016 / Access 2010 / Last Revised: 11/13/2017

Topic 03 - Objects and Classes. I. Classes and Objects Casual Preview. Topic 03. VIII. Benefits of Encapsulation. XIII. Overloading methods, Signature

ECSE 321 Assignment 2

Exam 2 ITEC 120 Principles of Computer Science I Spring: 2017

Asks for clarification of whether a GOP must communicate to a TOP that a generator is in manual mode (no AVR) during start up or shut down.

MONITORING REPORT ON THE WEBSITE OF THE STATISTICAL SERVICE OF CYPRUS DECEMBER The report is issued by the.

II. Compiling and launching from Command-Line, IDE A simple JAVA program

Scientific Programming in C X. More features & Fortran interface

I I. I I Wed 28-Jan-I WW1 - External Data I. EPF 29.5 Water Results. Consent of copyright owner required for any other use.

software.sci.utah.edu (Select Visitors)

Lecture 10: Boolean Expressions

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

High Performance Computing

Package taskscheduler

ICT PROFESSIONAL MICROSOFT OFFICE SCHEDULE MIDRAND

Database Programming with SQL

CS Programming I: Arrays

Dean Harrison IBM. Date of presentation (03/11/2015) Session NE. WAPL A Sheepdog in the Pen

FREQUENTLY ASKED QUESTIONS

Programming Language Concepts: Lecture 2

A Hybrid Constraint Programming Approach to Nurse Rostering Problem

Pennington County Government Justice Center. Schematic Design - October 27, 2015

Section 1.2: What is a Function? y = 4x

18050 (2.48 pages/visit) Jul Sep May Jun Aug Number of visits

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CIMA Asia. Interactive Timetable Live Online

CS141 Programming Assignment #6

Payflow Implementer's Guide FAQs

CS111: PROGRAMMING LANGUAGE II

HPE Security Data Security. HPE SecureData. Product Lifecycle Status. End of Support Dates. Date: April 20, 2017 Version:

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

DOWNLOAD OR READ : YEAR PLANNER 2014 WORD DOCUMENT VIEW PDF EBOOK EPUB MOBI

Location: Planet Laser Interview Skills Workshop

Date & Time Handling In JAVA

Programming Language Concepts: Lecture 2

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

Excel Functions & Tables

Definition: Data Type A data type is a collection of values and the definition of one or more operations on those values.

Contents. SCHTASKS CLI enables an administrator to manage scheduled tasks. SCHTASKS /parameter [arguments] SCHTASKS /Run

CIMA Asia. Interactive Timetable Live Online

Conditional Formatting

Advancing the Art of Internet Edge Outage Detection

Troop calendar

More Binary Search Trees AVL Trees. CS300 Data Structures (Fall 2013)

AP COMPUTER SCIENCE A

1 of 10 8/10/2009 4:51 PM

Data Types H&K Chapter 7. Instructor - Andrew S. O Fallon CptS 121 (October 17, 2018) Washington State University

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I

More BSTs & AVL Trees bstdelete

SUN Sun Certified Associate for the Java Platform.

SCHEDULED PROGRAMMES/COURSES APRIL 2017 MARCH 2018 (MIND KINGSTON / MANDEVILLE CAMPUSES & MONTEGO BAY)

SHADOW - Main Result. windpro EFFECTEN SLAGSCHADUW HERENTALS GEPLANDE WINDTURBINES HERENTALS. EDF Luminus Markiesstraat Brussel

HE AIR FORCE SCHOOL: SUBROTO PARK: DELHI CANTT WT-II SUB: INFORMATICS PRACTICES ANSWER KEY. 1. (a) What will be the output of the code 2

OPERATING MANUAL FOR AUTOMATIC SCHOOL BELL Ringing bell in manual mode: When unit is at Home Screen, showing date and time on

CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011

All King County Summary Report

10) LEVEL 4 Assessment Success Pack. EOY Target: Teacher: WA Grade: Targets: Name: Class:

SCHEDULED PROGRAMMES/COURSES APRIL 2018 MARCH 2019 (MIND KINGSTON / MANDEVILLE CAMPUSES & MONTEGO BAY)

Chapter 7: Structuring the Data. Lecture7 1

Statistics for web9 (2008)

Statistics for cornish-maine.org ( ) - main

Objects and Classes. Objects and Classes

SCI - software.sci.utah.edu (Select Visitors)

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

CS141 Programming Assignment #8

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

Question 1 [20 points]

BatteryStats.com Page 1 of 9

OBJECT-ORIENTED PROGRAMMING IN R: S3 & R6. Environments, Reference Behavior, & Shared Fields

10/16/2016 CPET 490 SENIOR DESIGN PROJECT PHASE I ANDROID GOLF STATISTICS TRACKER. Brad Sorensen Kory Martin PROJECT SUMMARY

libname learn "C:\sas\STAT6250\Examples"; /*Identifies library of data*/

! This week: Chapter 6 all ( ) ! Formal parameter: in declaration of class. ! Actual parameter: passed in when method is called

Seattle (NWMLS Areas: 140, 380, 385, 390, 700, 701, 705, 710) Summary

Chapter 3. Ch 1 Introduction to Computers and Java. Selections

Operator overloading: extra examples

Unique visitors Number of visits Pages Hits Bandwidth (1.64 visits/visitor) 850 (2.47 Pages/Visit)

COURSE LISTING. Courses Listed. with SAP Hybris Marketing Cloud. 24 January 2018 (23:53 GMT) HY760 - SAP Hybris Marketing Cloud

3. EXCEL FORMULAS & TABLES

FIA INTENSIVE REVISION - June 2018 EXAM

Transcription:

Lecture Notes: ESC 101 Date: 26/02/2008 // Program to Display calendar of a given month import java.util.scanner; class Year int year; Year() this.year=2000; Year(int y) year=(y>1900)? y:1900; //if year less than 1900, set it to 1900 Year(Year y) //copy constructor // used during assignment operation between two year elements this.year = y.year; boolean isleap(int year) if((year % 400)==0) return true;//if divisible by 400 return true if((year % 100)==0) return false;//if divisible by 100 but not by 400 if((year % 4)==0) return true; return false; int weekday() int date = Date.MON; //First day of week int i; //To find the day on 1st Jan of Current year for(i=1900;i<year;i++) date = (date + 365+ (isleap(i)?1 : 0)) % 7 ; return date;

public String tostring() return "" + year; //return year as string class Month public final static int JAN = 1; public final static int FEB = 2; public final static int MAR = 3; public final static int APR = 4; public final static int MAY = 5; public final static int JUN = 6; public final static int JUL = 7; public final static int AUG = 8; public final static int SEP = 9; public final static int OCT = 10; public final static int NOV = 11; public final static int DEC = 12; public final static String monthshortname[] = "JAN","FEB","MAR","APR","MAY","JUN","JUL,"AUG","SEP","OCT","NOV","DEC"; public final static String monthfullname[] = "JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBE R","OCTOBER","NOVENBER","DECEMBER"; private int month; //int as private member private Year year; //object of type Year as private member Month(int month,int year) this.month = ((month < JAN) (month > DEC))? JAN:month ; //Assign this.month with month in parameter otherwise with JAN if month in parameter is less than 0(JAN) or greater 12(DEC) this.year = new Year(year); Month(int month) this.month = ((month < JAN) (month > DEC ))?JAN:month; this.year = new Year();

Month() this.month = JAN; this.year = new Year(); Month(Month m) this.month = m.month; this.year = new Year(m.year); //find the no of days in the month. private int lastday(int month) int i = this.year.year; switch(month) //using switch case on month to find the no: of days in the month. int lastday() case MAR: case JUN: case SEP: case NOV: return 30; case FEB: return ((year.isleap(i))?29:28); default : return 31; return lastday(month); //calling the lastday fun. with current month as parameter to it.

//To find the day on 1st of Current month int weekday() int i; int first = year.weekday(); for(i = JAN; i<month; i++) first = (first + lastday(i)) % 7; return first; public String tostring() return monthfullname[month - 1] + " " + year; public int[][] calender() int[][] calarray = new int[5][7]; // A month can have at most 5 weeks and 7 days per week... 4 entries will remain vacant int i = weekday(); // Day of the 1st of the current month int j; for(j=0; j<lastday(); j++) int t = i+j; calarray[(t/7)%5][t%7] = j+1; return calarray;

class Date public final static int SUN=0; public final static int MON=1; public final static int TUE=2; public final static int WED=3; public final static int THU=4; public final static int FRI=5; public final static int SAT=6; public final static String dayshortname[] = "SUN","MON","TUE","WED","THU", "FRI","SAT"; public final static String dayfullname[] = "SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY", "FRIDAY","SATURDAY"; private int day; Month month; Date(int day,int month,int year) this.month =new Month(month,year); this.day=(day>this.month.lastday() day<1)?1:day; Date(int day,int month) this.month =new Month(month); this.day=(day>this.month.lastday() day<1)?1:day; Date(int day) this.month =new Month(); this.day=(day>this.month.lastday() day<1)?1:day; Date() this.month=new Month(); this.day=1; Date (Date d) this.month=new Month(d.month); this.day=d.day;

//To find the day on current date int weekday() return (this.month.weekday()+this.day-1)%7; public String tostring() return ""+day+" "+month; class Calender public static void main(string a[]) Scanner s = new Scanner (System.in); (>1900)"); System.out.println(" Enter day (1-31) month (1-12) and year int day=s.nextint(); int month=s.nextint(); int year=s.nextint(); Date d = new Date(day,month,year); System.out.println(d+" is / was a "+ Date.dayFullName[d.weekDay()]+"\n\n"); int [][]cal = d.month.calender(); System.out.println(d.month); int i=0, j=0; for(j=0;j<7;j++) System.out.print(" "+Date.dayShortName[j]); System.out.println(" "); for(i=0;i<5;i++) for(j=0;j<7;j++) if(cal[i][j]==0) System.out.print(" ");

else if( cal[i][j]<10) System.out.print(" "+cal[i][j]); else System.out.print(" "+cal[i][j]); System.out.println(""); Multi- Dimensional Arrays: Once an array is created its size cannot be changed. Box is abstraction of memory. Unit of memory is Byte. Byte is a data type that occupies 1 memory location and Short is a data type that occupies 2 memory locations etc. There is a mechanism by which array can be represented in memory. Eg. Byte array[5](1-d array of 5 Bytes ) will occupy 5 memory locations. 2 D Array of Bytes: Consider an array, Byte array[5][7]. Its elements will be stored in following way:

0,0 0,1 0,2 0,3 0,4 0,5 0,6 1,0 1,1 1,2 1,3 1,4 1,5 1,6 2,0 2,1 2,2 2,3 2,4 2,5 2,6 3,0 3,1 3,2 3,3 3,4 3,5 3,6 4,0 4,1 4,2 4,3 4,4 4,5 4,6 First memory location will contain array element [0][0]. Next memory location will contain element [0][1] and so on. Here elements are stored Row-wise. This way of storing elements is referred as Row Major Order. Java uses Row major order. There is another way of storing these elements in which first memory location contains element [0][0] and next memory location contains element[1][0] i.e. here elements are stored Column-wise. This way of storing is referred as Column Major Order.