Computational Applications in Nuclear Astrophysics using Java Java course Lecture 3

Similar documents
Computational Applications in Nuclear Astrophysics using Java Java course Lecture 4

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 2

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 1

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 6

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Programming in C++ PART 2

Introduction to Programming Using Java (98-388)

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017

COMP Primitive and Class Types. Yi Hong May 14, 2015

Comp Assignment 2: Object-Oriented Scanning for Numbers, Words, and Quoted Strings

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

CS1004: Intro to CS in Java, Spring 2005

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

ECE 122. Engineering Problem Solving with Java

Organizing and Summarizing Data

Lesson 8 - Practice Problems

CSC Java Programming, Fall Java Data Types and Control Constructs

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

CS313D: ADVANCED PROGRAMMING LANGUAGE

COP 3014: Fall Final Study Guide. December 5, You will have an opportunity to earn 15 extra credit points.

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

What is PHP? [1] Figure 1 [1]

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Second Year C and R Assignment

Chapter 6. Arrays. Java Actually: A Comprehensive Primer in Programming

Lesson 11 Rational Functions

Decision Making and Loops

The parametric equation below represents a ball being thrown straight up. x(t) = 3 y(t) = 96t! 16t 2

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 25, 2016

CS 61B Discussion 5: Inheritance II Fall 2014

Lecture 8 CSE11 Fall 2013 While Loops, Switch Statement, Simplifying Conditionals

The List Datatype. CSc 372. Comparative Programming Languages. 6 : Haskell Lists. Department of Computer Science University of Arizona

CS61C : Machine Structures

CIS192: Python Programming

Structured Programming

Java Programming. Manuel Oriol, March 22nd, 2007

Object Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang

Setting a Window - Finding One That Works. You can enter the dimensions of the graph by accessing button you will see a window like the one below.

Honors Algebra 3-4 Mr. Felling Expanded Topic - Curve Fitting Extra Credit Project

Computer Programming: C++

Root programming and data analysis

Q. State and Explain steps involved in program development. [w-08, w-10, s-12, w-11]

Chapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes

Repetition Structures II

I ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place?

CS210 Project 5 (Kd-Trees) Swami Iyer

Calculator Tables and Graphs

CMSC 330: Organization of Programming Languages. Lets, Tuples, Records

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

Chpt 1. Functions and Graphs. 1.1 Graphs and Graphing Utilities 1 /19

Structures, Operators

MATLAB. MATLAB Review. MATLAB Basics: Variables. MATLAB Basics: Variables. MATLAB Basics: Subarrays. MATLAB Basics: Subarrays

Lesson 2.4 Arraylist

python 01 September 16, 2016

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

Chapel Introduction and

Embedded Controller Programming 2

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef

Lines and Circles Guided Practice: Teacher Instructions

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file?

S-1. Concepts this lecture. CSE 142 Computer Programming I. Chapter 11. Review: Data Structures. Problem: Account Records.

Computer Programming: Skills & Concepts (CP) arithmetic, if and booleans (cont)

Repetition Structures

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

CS 361 Computer Systems Fall 2017 Homework Assignment 4 - Inter-Process Communications & I/O

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Thursday, February 16, More C++ and root

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

DATA STRUCTURES USING C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators

F1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept

Chapter. Implicit Function Graphs

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Principles of Autonomy and Decision Making

QUIZ. Can you find 5 errors in this code?

W3101: Programming Languages C++ Ramana Isukapalli

Fundamentals of Programming Session 13

Section 1.6. Inverse Functions

CS111: PROGRAMMING LANGUAGE II

Assignment #2: Intro to Java Due: 11AM PST on Wednesday, July 12

ESc101 : Fundamental of Computing

Programming, numerics and optimization

CISC 1600, Lab 3.1: Processing

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Programming Using C Homework 5

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

Writeup for first project of CMSC 420: Data Structures Section 0102, Summer Theme: Threaded AVL Trees

CSE : Python Programming

Loops. Repeat after me

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Lesson 10: Quiz #1 and Getting User Input (W03D2)

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

2nd Year Computational Physics Week 1 (experienced): Series, sequences & matrices

Clouds, biological growth, and coastlines are

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

Transcription:

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 3 Prepared for course 160410/411 Michael C. Kunkel m.kunkel@fz-juelich.de Materials taken from; docs.oracle.com Teach Yourself Java ISBN 9780078825705

Maven Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. https://maven.apache.org/

Maven We will use maven for our project dependancies Lets look at our pom file you have from the Github project

Java

Java

Methods in Java A method is a block of statements that are grouped together to perform an operation or specific task The equivalent of Java methods in C and C ++ are functions Methods are used to divide code into logical pieces Methods can return values, or just perform an operation

Class Work Create a package in Eclipse Name it thirdclass Create a public class named MyMethods Lets create a method called printhello that will take 2 arguments of String and int Example on next slide Create a main method call the printhello method

Java

Class Work Using the package thirdclass Using the public class named MyMethods Lets create a method called printstring that will take 0 arguments and return a String Example on next slide In the main method call the string value of printstring

Class Work

Method Overloading A class can have multiple methods having the same name but different parameters. This is known as method overloading Having the same method name that performs the same operation increases the readability of a program To overload a method Change the number of parameter Change the data type of of one parameter In Java it is not possible to overload a method by simply changing the return type.

Class Work Using the package thirdclass Using the public class named MyMethods Lets create a method called myoverload that will take 1 parameter Lets overload the method called myoverload 2 parameters " "3 parmeters Example on next slide In the main method call all 3 overloaded methods

Class Work

Class Work Using the package thirdclass Using the public class named OnlyGravitationalHeating Keep the mass and luminosity of the sun constant, write a method that will return what the radius of the sun would be today, if the only source of energy was gravitational heating Overload this method to take an integer as input and return the radius of the sun if it were to have enough heat for X*ageOfSun You may use the Constants package

Class Work Using the package thirdclass Using the public class named SemiEmpiricalMassFormula Write a method that returns the binding energy for parameters N and Z You may use the Constants package You may update the Constants package

Java Loops for loop A for loop is a looping stamens that allows you to execute a code block a specific amount of times for(initialization;termination;incerement)

Java Loops A nested for loop A nested for loop is a for loop in a for loop

Java Loops for loop can also be missing some of its body Be careful, without the termination, you will get an infinite loop...try it! Press the red box in Eclipse to stop

Java Loops A foreach loop creates a loop that returns for each element of an array or iterable objects from the objects first element to its last

Java Loops A while is a loop that repeats while a condition is true Be careful, without the increment, you will get an infinite loop...try it! Press the red box in Eclipse to stop Can be used on char. Try it, start from k='a' until k<='z' print the value of k

Java Loops A do-while loop is a loop that repeats while the condition is true. However, unlike a while loop, a do-while is checked at the bottom of the loop. Loops always get processed once!! Will not print anything = Will print. What will is print?

Visualizing Data in Java To visualize data, programmers usually use graphs or histograms. In this class we will use the COATJava package developed at the CEBAF Large Acceptance Spectrometer at The Jefferson National Laboratory

Visualizing Data in Java We have already imported the necessary dependancies with our POM file To instantiate a Graph GraphErrors gr = new GraphErrors(); To fill a graph gr.addpoint(x,y,errorx, errory);

Visualizing Data in Java To instantiate a Histogram 1 Dimensional H1F ah1f = new H1F(name, bins, xmin, xmax); 2 Dimensional H2F ah2f = new H2F(name, title, bx, xmin, xmax, by, ymin, ymax); To fill a Histogram ah1f.fill(bin,value); ah2f.fill(binx, biny, value);

Visualizing Data in Java To visualize a graph or histogram After the graph has all values TCanvas canvas = new TCanvas("a Canvas", 800, 800); canvas.draw(gr); To save a graph, use the domain.utils package SaveCanvas.saveCanvas(canvas);

Visualizing Data in Java Solar radius with only gravitational heating 0.0020 Solar radius [r sun] 0.0015 0.0010 0.0005 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 Solar age [t sun]

Homework Make a graph in that shows radius of the sun for 1*ageOfSun-20*ageOfSun (put in units of current solar radius) Submit to Github Extra Credit Try to use Eclipse's content assist to find how to label the x and y axes, as well as give a name to the graph/plot (If you label you should also use units!!)

Next Class More Java Code examples from lecture 2 lecture 3