Math methods. Lecture Seven Math methods. GUI review Interest Calculator. Read Chapter 5, pg. 115
|
|
- Oliver Marshall
- 7 years ago
- Views:
Transcription
1 Lecture Seven Math methods GUI review Interest Calculator Math methods Math comparisons Math constants Formatting numbers Roll Dice program Random numbers Rounding numbers Casting Drill Read Chapter 5, pg
2 GUI review In the last lesson we created a simple calculator GUI. We will continue to build from that GUI in this lesson. There are still some GUI concepts that we are using but have not gone over in detail. Don t t worry too much about why things work the way they do we will go over in detail the inner workings of GUIs in future lessons. 2
3 GUI review Recall the major steps we took when we constructed our SimpleCalc program 1. Import library packages 2. Open the class 3. Declare the components 4. Write a main method 5. Begin the constructor method 6. Select a layout manager 7. Add components to the layout 8. Add listeners to buttons and the window 9. Write the actionperformed method 10. Complete the WindowListener 3
4 Interest calculator Suppose we have just written a Java program and a major software company has purchased it from us for $500,000. We decide we want to invest this money but there are so many options! There are CDs at 4.5%, compounded yearly for 10 years; money market accounts at 4.0%, compounded monthly, etc. Our goal is to write a simple interest calculator that we can use to determine how much money we would earn by investing our money in these different types of accounts. 4
5 Interest calculator Compound interest is determined by the following equation: B = P * (1 + r/c) c*n Where B = ending balance P = initial principal amount invested r = interest rate c = number of times amount is compounded per year n = number of years invested Furthermore, we can determine the amount of money we made by subtracting our initial principal from our ending balance (B( P) 5
6 Interest calculator We decide we want our interface to look something like this: 6
7 Interest calculator We will now write our InterestCalc using the same steps we took to create our SimpleCalc Follow along and (as always) write the program as we go! 7
8 Step 1: Import library packages // For GUI stuff import java.awt.*;.*; import javax.swing.*;.*; import java.awt.event.*;.*; // For Math functions and NumberFormat import java.lang.math; import java.text.*;.*; This is just like the SimpleCalc program except we also add libraries for Math and NumberFormat classes 8
9 Step 2: Declare the class InterestCalc // For Math functions and NumberFormat import java.lang.math; import java.text.*;.*; // Create class public class InterestCalc extends JFrame implements ActionListener, WindowListener { 9
10 Step 3: Declare the components { // Declare GUI components private JLabel principallabel; private JTextField principalfield; private JLabel ratelabel; private JTextField ratefield; private JLabel compoundlabel; private JTextField compoundfield; private JLabel yearslabel; private JTextField yearsfield; private JLabel balancelabel; private JTextField balancefield; private JLabel moneylabel; private JTextField moneyfield; private JButton calculatebutton; 10
11 Step 4: Write the main method... private JButton calculatebutton; // main method public static void main(string args[]) { } JFrame frame = new InterestCalc(); frame.setsize(350, 250); frame.settitle("interest Calculator"); frame.setvisible(true); 11
12 Step 5: Begin the constructor method // constructor public InterestCalc() { principallabel = new JLabel(" Initial Principal: "); principalfield = new JTextField(); // no initial value or width ratelabel = new JLabel(" Interest Rate: "); ratefield = new JTextField(); compoundlabel = new JLabel(" Compound Times Per Year:"); compoundfield = new JTextField(); yearslabel = new JLabel(" Years: "); yearsfield = new JTextField(); balancelabel = new JLabel(" Ending Balance: "); balancefield = new JTextField(); moneylabel = new JLabel(" Money Made: "); moneyfield = new JTextField(); calculatebutton = new JButton("Calculate"); "); 12
13 Step 6: Select and set a layout manager In the SimpleCalc we used a FlowLayout.. For our InterestCalc we will learn about a new layout, GridLayout (see pg 115) When creating a new GridLayout,, you must pass two arguments to the method. The first is the number of rows in your grid, the second is the number of columns in your grid. GridLayout will then divide the frame into a grid and will add components from left to right, top to bottom One thing to note about GridLayout is that components are resized to fit entirely into the grid space allocated for that component. (This is why there was no need to specify a field width when we created our JTextFields in the previous slide.) 13
14 Step 6: Select and set a layout manager... calculatebutton = new JButton("Calculate"); "); // create layout // grid layout with 7 rows and 2 columns GridLayout layout = new GridLayout(7, 2); Container window = getcontentpane(); window.setlayout(layout); 14
15 Step 7: Add the components to the layout // add components to window window.add(principallabel); window.add(principalfield); window.add(ratelabel); window.add(ratefield); window.add(compoundlabel); window.add(compoundfield); window.add(yearslabel); window.add(yearsfield); window.add(balancelabel); window.add(balancefield); window.add(moneylabel); window.add(moneyfield); window.add(calculatebutton); 15
16 Step 8: Add listeners to button and window... window.add(calculatebutton); // add action listeners calculatebutton.addactionlistener(this); addwindowlistener(this); } // close constructor 16
17 Step 9: Write the actionperformed method // action performed method public void actionperformed (ActionEvent e) { String tempstring; double principal, rate, compound, balance, years, moneymade; NumberFormat currency = NumberFormat.getCurrencyInstance(); if (e.getsource( e.getsource() == calculatebutton) { // get data and convert to doubles tempstring = principalfield.gettext().trim(); (); principal = (new Double(tempString)).doubleValue(); (); tempstring = ratefield.gettext().trim(); (); rate = (new Double(tempString)).doubleValue() () / 100.0; tempstring = compoundfield.gettext().trim(); (); compound = (new Double(tempString)).doubleValue(); (); tempstring = yearsfield.gettext().trim(); (); years = (new Double(tempString)).doubleValue(); (); 17
18 Step 9: Write the actionperformed method (cont)... years = (new Double(tempString)).doubleValue(); (); // calculate balance and money made balance = Math.pow(1.0 +rate/compound, compound * years) * principal; moneymade = balance - principal; } } // output balance and money made in text box as currency balancefield.settext(currency.format(balance)); moneyfield.settext(currency.format(moneymade)); 18
19 Step 10: Complete the WindowListener // window actions public void windowclosing(windowevent e) { System.exit(0); } public void windowactivated(windowevent e){} public void windowclosed(windowevent e){} public void windowdeactivated(windowevent e){} public void windowiconified(windowevent e){} public void windowdeiconified(windowevent e){} public void windowopened(windowevent e){} } // close InterestCalc class 19
20 Interest calculator Compile the code and see if it works. Investing my money into a 10 year CD at 4.5% interest compounded monthly looks like a good deal! 20
21 Math methods The InterestCalc program uses a method from the Math class pow() which takes 2 arguments: a base and an exponent In order to use methods from the Math class we must import java.lang.math; A list of commonly used Math methods are listed in your textbook on pg
22 Math methods (cont) Most of the methods listed take a single argument (with the exception of max(), min(), and pow() which all take 2 arguments) Most methods also have a return type of type double Exceptions: abs() returns the same type of value that was used as an argument max() & min() returns a value that is the same type as the argument with the most precision (more on this later) round() returns the int value that is closest to the double passed in as an argument 22
23 Math comparisons Two special Math methods max() and min() can be used to compare two numbers Each method takes two numbers as arguments and will return the number that is either the greatest (max) or the least (min) The return type is determined by the argument with the greatest precision For example, System.out.println(Math.max(24, 23.0)); // this will print 24.0 NOT 24 since the argument with // greatest precision is 23.0, which is a double 23
24 Math constants In addition to the Math methods, there are also 2 Math constants These constants are of type double and can be used in programs to perform certain calculations The two constants are: Math.PI value of pi Math.E value of base of natural logs For example, to calculate the area of a circle given a radius, r,, would be area = Math.PI * pow(r,, 2); 24
25 Formatting numbers In addition to using Math methods in the InterestCalc program, we also used some methods from the NumberFormat class in order to format the output of our balance as currency In order to use NumberFormat we need to import java.text.*;.*; Once we import the library we then need to create a NumberFormat instance. In our program we did this with this line of code: NumberFormat currency = NumberFormat.getCurrencyInstance(); 25
26 Formatting numbers (cont) NumberFormat currency = NumberFormat.getCurrencyInstance(); This line of code created a currency format. We can also create other formats by calling the getnumberinstance() or getpercentinstance() methods. getnumberinstance() will format numbers with added commas (Ex: becomes 1,000,000) getpercentinstance() will format numbers as percentages (Ex: 0.75 becomes 75%) 26
27 Formatting numbers (cont) Once we create a format we must then specify which value we want to format. In our example we created a format named currency and wanted to apply it to our variable named balance To do this we called the format() method which then returns a String that we could display in our JTextField balancefield balancefield.settext(currency.format(balance)); 27
28 Roll Dice program Let s s take a look at another example that uses other Math methods For this example we are going to create a Dice emulator (i.e. a program that mimics the act of rolling dice) We will pretend we have a pair of dice and want to generate a random roll each time the Roll button is pressed Again, we can modify our previous GUIs to achieve this However, we will not go through the 10 steps to create the GUI (you should be familiar with them by now) 28
29 Roll Dice program code (1) // For GUI stuff import java.awt.*;.*; import javax.swing.*;.*; import java.awt.event.*;.*; // For Math functions import java.lang.math; // Create class public class RollDice extends JFrame implements ActionListener, WindowListener { // Declare GUI components private JLabel displaylabel; private JButton rollbutton; 29
30 Roll Dice program code (2) // main method public static void main(string args[]) { JFrame frame = new RollDice(); frame.setsize(150, 100); frame.settitle("roll Dice"); frame.setvisible(true); } // constructor public RollDice() { displaylabel = new JLabel("Click Roll"); rollbutton = new JButton("Roll"); "); 30
31 Roll Dice program code (3) // create layout FlowLayout layout = new FlowLayout(); Container window = getcontentpane(); window.setlayout(layout); // add components to window window.add(displaylabel); window.add(rollbutton); // add action listeners rollbutton.addactionlistener(this); addwindowlistener(this); } 31
32 Roll Dice program code (4) // action performed method public void actionperformed (ActionEvent e) { } int die1, die2; if (e.getsource( e.getsource() == rollbutton) { } die1 = (int( int) Math.ceil(Math.random() () * 6); die2 = (int( int) Math.ceil(Math.random() () * 6); displaylabel.settext("you rolled a " + die1 + " and a " + die2); 32
33 Roll Dice program code (5) } // window actions public void windowclosing(windowevent e) { } System.exit(0); public void windowactivated(windowevent e){} public void windowclosed(windowevent e){} public void windowdeactivated(windowevent e){} public void windowiconified(windowevent e){} public void windowdeiconified(windowevent e){} public void windowopened(windowevent e){} 33
34 Random numbers Our RollDice program should not have any unfamiliar components in terms of the GUI The only lines of code that should be new to you are: die1 = (int( int) Math.ceil(Math.random() () * 6); die2 = (int( int) Math.ceil(Math.random() () * 6); Let s s take a look at this line of code piece by piece 34
35 Random numbers (cont) die1 = (int( int) Math.ceil(Math.random Math.random() * 6); 6 We ll start by looking from the inside out. The first thing we see is Math.random() * 6 The random() method is used to create a random number of type double that is between 0.0 and 1.0 Because we want to generate a number that is a valid die roll we need to multiply our number by 6 which then gives us a random number between 0.0 and
36 Rounding numbers die1 = (int( int) Math.ceil(Math.random Math.random() * 6); 6 The next command we use is Math.ceil() which is a rounding command used to round numbers up Since it is impossible to have a die roll of 0 we use this command to round our random number up, thus giving us a new range of random numbers between 1.0 and 6.0 Other rounding commands include floor() (which rounds a number down) and round() (which rounds a number either down or up) 36
37 Casting die1 = (int) Math.ceil(Math.random() () * 6); The final part of this statement is the (int) part which is called a cast Since the result of our Math methods are doubles we must cast the results to an int (because we wouldn t want a die roll of 5.9) Casting is used to convert numbers of one type to another type In our example we cast down because we cast a value of type double down to a value of type integer (which has less precision). We can also cast values up. When casting down there is the potential for precision and data loss because values may be truncated. For example, casting a double (say 5.9) down to an integer will result in 5 (not 6). 37
38 Drill 7 1.Create an angle calculator GUI. That is, allow the user to enter an angle into a field as degrees. Display that value as radians and also give the sin, cos,, and tan of the angle. Try using the GridLayout like we did in the InterestCalc.. Hint: the trig methods require their arguments be in radians, not degrees. 38
39 Drill 7 (cont.) 2.Create a GUI that can find the two roots of a quadratic function. Allow the user to specify values for a, b, and c. For those of you who are rusty on your algebra that means we want to find where ax 2 + bx + c = 0 To do this we can solve using the quadratic equation: x = -b ± b 2a 2 4ac 39
40 Drill 7 (cont.) 3.Create a GUI that asks a user to guess a number between 1 and 10. Then, randomly generate a number between 1 and 10 and tell the user whether or not he or she guessed correctly. 40
public class Craps extends JFrame implements ActionListener { final int WON = 0,LOST =1, CONTINUE = 2;
Lecture 15 The Game of "Craps" In the game of "craps" a player throws a pair of dice. If the sum on the faces of the pair of dice after the first toss is 7 or 11 the player wins; if the sum on the first
More informationProgramming with Java GUI components
Programming with Java GUI components Java includes libraries to provide multi-platform support for Graphic User Interface objects. The multi-platform aspect of this is that you can write a program on a
More informationINTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction
INTRODUCTION TO COMPUTER PROGRAMMING Richard Pierse Class 7: Object-Oriented Programming Introduction One of the key issues in programming is the reusability of code. Suppose that you have written a program
More information5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung
AWT vs. Swing AWT (Abstract Window Toolkit; Package java.awt) Benutzt Steuerelemente des darunterliegenden Betriebssystems Native Code (direkt für die Maschine geschrieben, keine VM); schnell Aussehen
More informationCS 335 Lecture 06 Java Programming GUI and Swing
CS 335 Lecture 06 Java Programming GUI and Swing Java: Basic GUI Components Swing component overview Event handling Inner classes and anonymous inner classes Examples and various components Layouts Panels
More information// Correntista. //Conta Corrente. package Banco; public class Correntista { String nome, sobrenome; int cpf;
// Correntista public class Correntista { String nome, sobrenome; int cpf; public Correntista(){ nome = "zé"; sobrenome = "Pereira"; cpf = 123456; public void setnome(string n){ nome = n; public void setsobrenome(string
More informationHomework/Program #5 Solutions
Homework/Program #5 Solutions Problem #1 (20 points) Using the standard Java Scanner class. Look at http://natch3z.blogspot.com/2008/11/read-text-file-using-javautilscanner.html as an exampleof using the
More informationGUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012
GUIs with Swing Principles of Software Construction: Objects, Design, and Concurrency Jonathan Aldrich and Charlie Garrod Fall 2012 Slides copyright 2012 by Jeffrey Eppinger, Jonathan Aldrich, William
More informationGraphical User Interfaces
M14_REGE1813_02_SE_C14.qxd 2/10/10 3:43 PM Page 822 Chapter14 Graphical User Interfaces 14.1 GUI Basics Graphical Input and Output with Option Panes Working with Frames Buttons, Text Fields, and Labels
More informationThe Method of Partial Fractions Math 121 Calculus II Spring 2015
Rational functions. as The Method of Partial Fractions Math 11 Calculus II Spring 015 Recall that a rational function is a quotient of two polynomials such f(x) g(x) = 3x5 + x 3 + 16x x 60. The method
More informationHow To Build A Swing Program In Java.Java.Netbeans.Netcode.Com (For Windows) (For Linux) (Java) (Javax) (Windows) (Powerpoint) (Netbeans) (Sun) (
Chapter 11. Graphical User Interfaces To this point in the text, our programs have interacted with their users to two ways: The programs in Chapters 1-5, implemented in Processing, displayed graphical
More informationWeek 13 Trigonometric Form of Complex Numbers
Week Trigonometric Form of Complex Numbers Overview In this week of the course, which is the last week if you are not going to take calculus, we will look at how Trigonometry can sometimes help in working
More informationAdvanced Network Programming Lab using Java. Angelos Stavrou
Advanced Network Programming Lab using Java Angelos Stavrou Table of Contents A simple Java Client...3 A simple Java Server...4 An advanced Java Client...5 An advanced Java Server...8 A Multi-threaded
More informationExtending Desktop Applications to the Web
Extending Desktop Applications to the Web Arno Puder San Francisco State University Computer Science Department 1600 Holloway Avenue San Francisco, CA 94132 arno@sfsu.edu Abstract. Web applications have
More informationhttp://netbeans.org/kb/docs/java/gui-functionality.html?print=yes
Page 1 of 6 Introduction to GUI Building Contributed by Saleem Gul and Tomas Pavek, maintained by Ruth Kusterer and Irina Filippova This beginner tutorial teaches you how to create a simple graphical user
More informationLab 1A. Create a simple Java application using JBuilder. Part 1: make the simplest Java application Hello World 1. Start Jbuilder. 2.
Lab 1A. Create a simple Java application using JBuilder In this lab exercise, we ll learn how to use a Java integrated development environment (IDE), Borland JBuilder 2005, to develop a simple Java application
More informationCallbacks. Callbacks Copyright 2007 by Ken Slonneger 1
Callbacks Callbacks refer to a mechanism in which a library or utility class provides a service to clients that are unknown to it when it is defined. Suppose, for example, that a server class creates a
More information5.3 SOLVING TRIGONOMETRIC EQUATIONS. Copyright Cengage Learning. All rights reserved.
5.3 SOLVING TRIGONOMETRIC EQUATIONS Copyright Cengage Learning. All rights reserved. What You Should Learn Use standard algebraic techniques to solve trigonometric equations. Solve trigonometric equations
More informationUsing A Frame for Output
Eventos Roteiro Frames Formatting Output Event Handling Entering Data Using Fields in a Frame Creating a Data Entry Field Using a Field Reading Data in an Event Handler Handling Multiple Button Events
More informationCS170 Lab 11 Abstract Data Types & Objects
CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the
More informationUnit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.
Unit 1 Number Sense In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions. BLM Three Types of Percent Problems (p L-34) is a summary BLM for the material
More informationSession 7 Fractions and Decimals
Key Terms in This Session Session 7 Fractions and Decimals Previously Introduced prime number rational numbers New in This Session period repeating decimal terminating decimal Introduction In this session,
More informationSAT Math Facts & Formulas Review Quiz
Test your knowledge of SAT math facts, formulas, and vocabulary with the following quiz. Some questions are more challenging, just like a few of the questions that you ll encounter on the SAT; these questions
More informationpublic class demo1swing extends JFrame implements ActionListener{
import java.io.*; import java.net.*; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class demo1swing extends JFrame implements ActionListener JButton demodulacion;
More informationMATH 10034 Fundamental Mathematics IV
MATH 0034 Fundamental Mathematics IV http://www.math.kent.edu/ebooks/0034/funmath4.pdf Department of Mathematical Sciences Kent State University January 2, 2009 ii Contents To the Instructor v Polynomials.
More informationReview of Fundamental Mathematics
Review of Fundamental Mathematics As explained in the Preface and in Chapter 1 of your textbook, managerial economics applies microeconomic theory to business decision making. The decision-making tools
More informationTom wants to find two real numbers, a and b, that have a sum of 10 and have a product of 10. He makes this table.
Sum and Product This problem gives you the chance to: use arithmetic and algebra to represent and analyze a mathematical situation solve a quadratic equation by trial and improvement Tom wants to find
More informationMath 10C. Course: Polynomial Products and Factors. Unit of Study: Step 1: Identify the Outcomes to Address. Guiding Questions:
Course: Unit of Study: Math 10C Polynomial Products and Factors Step 1: Identify the Outcomes to Address Guiding Questions: What do I want my students to learn? What can they currently understand and do?
More informationMath 115 Spring 2011 Written Homework 5 Solutions
. Evaluate each series. a) 4 7 0... 55 Math 5 Spring 0 Written Homework 5 Solutions Solution: We note that the associated sequence, 4, 7, 0,..., 55 appears to be an arithmetic sequence. If the sequence
More information4. How many integers between 2004 and 4002 are perfect squares?
5 is 0% of what number? What is the value of + 3 4 + 99 00? (alternating signs) 3 A frog is at the bottom of a well 0 feet deep It climbs up 3 feet every day, but slides back feet each night If it started
More informationx 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1
Implicit Functions Defining Implicit Functions Up until now in this course, we have only talked about functions, which assign to every real number x in their domain exactly one real number f(x). The graphs
More informationPYTHAGOREAN TRIPLES KEITH CONRAD
PYTHAGOREAN TRIPLES KEITH CONRAD 1. Introduction A Pythagorean triple is a triple of positive integers (a, b, c) where a + b = c. Examples include (3, 4, 5), (5, 1, 13), and (8, 15, 17). Below is an ancient
More informationJava GUI Programming. Building the GUI for the Microsoft Windows Calculator Lecture 2. Des Traynor 2005
Java GUI Programming Building the GUI for the Microsoft Windows Calculator Lecture 2 Des Traynor 2005 So, what are we up to Today, we are going to create the GUI for the calculator you all know and love.
More informationTHE COMPLEX EXPONENTIAL FUNCTION
Math 307 THE COMPLEX EXPONENTIAL FUNCTION (These notes assume you are already familiar with the basic properties of complex numbers.) We make the following definition e iθ = cos θ + i sin θ. (1) This formula
More informationAlgebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123
Algebra Eponents Simplify each of the following as much as possible. 1 4 9 4 y + y y. 1 5. 1 5 4. y + y 4 5 6 5. + 1 4 9 10 1 7 9 0 Absolute Value Evaluate 5 and 1. Eliminate the absolute value bars from
More informationVieta s Formulas and the Identity Theorem
Vieta s Formulas and the Identity Theorem This worksheet will work through the material from our class on 3/21/2013 with some examples that should help you with the homework The topic of our discussion
More informationBinary Adders: Half Adders and Full Adders
Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order
More informationThe Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).
The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,
More informationEssentials of the Java(TM) Programming Language, Part 1
Essentials of the Java(TM) Programming Language, Part 1 http://developer.java.sun.com/developer...ining/programming/basicjava1/index.html Training Index Essentials of the Java TM Programming Language:
More informationContinued Fractions and the Euclidean Algorithm
Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction
More informationWelcome to Basic Math Skills!
Basic Math Skills Welcome to Basic Math Skills! Most students find the math sections to be the most difficult. Basic Math Skills was designed to give you a refresher on the basics of math. There are lots
More informationMATH 90 CHAPTER 6 Name:.
MATH 90 CHAPTER 6 Name:. 6.1 GCF and Factoring by Groups Need To Know Definitions How to factor by GCF How to factor by groups The Greatest Common Factor Factoring means to write a number as product. a
More informationTrigonometric Functions and Triangles
Trigonometric Functions and Triangles Dr. Philippe B. Laval Kennesaw STate University August 27, 2010 Abstract This handout defines the trigonometric function of angles and discusses the relationship between
More informationPart I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
More informationMATLAB Workshop 3 - Vectors in MATLAB
MATLAB: Workshop - Vectors in MATLAB page 1 MATLAB Workshop - Vectors in MATLAB Objectives: Learn about vector properties in MATLAB, methods to create row and column vectors, mathematical functions with
More informationSAT Subject Math Level 2 Facts & Formulas
Numbers, Sequences, Factors Integers:..., -3, -2, -1, 0, 1, 2, 3,... Reals: integers plus fractions, decimals, and irrationals ( 2, 3, π, etc.) Order Of Operations: Arithmetic Sequences: PEMDAS (Parentheses
More informationThe following four software tools are needed to learn to program in Java:
Getting Started In this section, we ll see Java in action. Some demo programs will highlight key features of Java. Since we re just getting started, these programs are intended only to pique your interest.
More informationAP Computer Science Java Mr. Clausen Program 9A, 9B
AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will
More informationFinding Rates and the Geometric Mean
Finding Rates and the Geometric Mean So far, most of the situations we ve covered have assumed a known interest rate. If you save a certain amount of money and it earns a fixed interest rate for a period
More informationSolving Rational Equations
Lesson M Lesson : Student Outcomes Students solve rational equations, monitoring for the creation of extraneous solutions. Lesson Notes In the preceding lessons, students learned to add, subtract, multiply,
More informationThe Center for Teaching, Learning, & Technology
The Center for Teaching, Learning, & Technology Instructional Technology Workshops Microsoft Excel 2010 Formulas and Charts Albert Robinson / Delwar Sayeed Faculty and Staff Development Programs Colston
More informationThe Basic Java Applet and JApplet
I2PUJ4 - Chapter 6 - Applets, HTML, and GUI s The Basic Java Applet and JApplet Rob Dempster robd@cs.ukzn.ac.za School of Computer Science University of KwaZulu-Natal Pietermaritzburg Campus I2PUJ4 - Chapter
More informationMATHS ACTIVITIES FOR REGISTRATION TIME
MATHS ACTIVITIES FOR REGISTRATION TIME At the beginning of the year, pair children as partners. You could match different ability children for support. Target Number Write a target number on the board.
More informationfile://c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html
file:c:\dokumente und Einstellungen\Marco Favorito\Desktop\ScanCmds.html Seite 1 von 5 ScanCmds.java ------------------------------------------------------------------------------- ScanCmds Demontration
More informationMath Review. for the Quantitative Reasoning Measure of the GRE revised General Test
Math Review for the Quantitative Reasoning Measure of the GRE revised General Test www.ets.org Overview This Math Review will familiarize you with the mathematical skills and concepts that are important
More informationInteractive Applications (CLI) and Math
Interactive Applications (CLI) and Math Interactive Applications Command Line Interfaces The Math Class Example: Solving Quadratic Equations Example: Factoring the Solution Reading for this class: L&L,
More informationLecture 2 Mathcad Basics
Operators Lecture 2 Mathcad Basics + Addition, - Subtraction, * Multiplication, / Division, ^ Power ( ) Specify evaluation order Order of Operations ( ) ^ highest level, first priority * / next priority
More informationAlgebra 2: Themes for the Big Final Exam
Algebra : Themes for the Big Final Exam Final will cover the whole year, focusing on the big main ideas. Graphing: Overall: x and y intercepts, fct vs relation, fct vs inverse, x, y and origin symmetries,
More informationLies My Calculator and Computer Told Me
Lies My Calculator and Computer Told Me 2 LIES MY CALCULATOR AND COMPUTER TOLD ME Lies My Calculator and Computer Told Me See Section.4 for a discussion of graphing calculators and computers with graphing
More informationLab 5: Bank Account. Defining objects & classes
Lab 5: Bank Account Defining objects & classes Review: Basic class structure public class ClassName Fields Constructors Methods Three major components of a class: Fields store data for the object to use
More informationC Programming Language
C Programming Language Lecture 4 (10/13/2000) Instructor: Wen-Hung Liao E-mail: whliao@cs.nccu.edu.tw Extension: 62028 Building Programs from Existing Information Analysis Design Implementation Testing
More informationSchueler-Organisiertes Lernen am Beispiel von Grafischen Benutzer-Schnittstellen in Java Tag der Offenen Tür - GTS 2008
Schueler-Organisiertes Lernen am Beispiel von Grafischen Benutzer-Schnittstellen in Java Tag der Offenen Tür - GTS 2008 http://worgtsone.scienceontheweb.net/worgtsone/ - mailto: worgtsone @ hush.com Sa
More informationPrime Time: Homework Examples from ACE
Prime Time: Homework Examples from ACE Investigation 1: Building on Factors and Multiples, ACE #8, 28 Investigation 2: Common Multiples and Common Factors, ACE #11, 16, 17, 28 Investigation 3: Factorizations:
More informationClick on the links below to jump directly to the relevant section
Click on the links below to jump directly to the relevant section What is algebra? Operations with algebraic terms Mathematical properties of real numbers Order of operations What is Algebra? Algebra is
More informationScanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard
INPUT & OUTPUT I/O Example Using keyboard input for characters import java.util.scanner; class Echo{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); // scanner for the keyboard
More informationHow to Convert an Application into an Applet.
How to Convert an Application into an Applet. A java application contains a main method. An applet is a java program part of a web page and runs within a browser. I am going to show you three different
More informationFACTORING QUADRATICS 8.1.1 and 8.1.2
FACTORING QUADRATICS 8.1.1 and 8.1.2 Chapter 8 introduces students to quadratic equations. These equations can be written in the form of y = ax 2 + bx + c and, when graphed, produce a curve called a parabola.
More informationCOMPLEX NUMBERS. a bi c di a c b d i. a bi c di a c b d i For instance, 1 i 4 7i 1 4 1 7 i 5 6i
COMPLEX NUMBERS _4+i _-i FIGURE Complex numbers as points in the Arg plane i _i +i -i A complex number can be represented by an expression of the form a bi, where a b are real numbers i is a symbol with
More informationSystem.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :
Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class
More information1 Hour, Closed Notes, Browser open to Java API docs is OK
CSCI 143 Exam 2 Name 1 Hour, Closed Notes, Browser open to Java API docs is OK A. Short Answer For questions 1 5 credit will only be given for a correct answer. Put each answer on the appropriate line.
More informationFactorizations: Searching for Factor Strings
" 1 Factorizations: Searching for Factor Strings Some numbers can be written as the product of several different pairs of factors. For example, can be written as 1, 0,, 0, and. It is also possible to write
More informationpublic class Application extends JFrame implements ChangeListener, WindowListener, MouseListener, MouseMotionListener {
Application.java import javax.swing.*; import java.awt.geom.*; import java.awt.event.*; import javax.swing.event.*; import java.util.*; public class Application extends JFrame implements ChangeListener,
More informationEssentials of the Java Programming Language
Essentials of the Java Programming Language A Hands-On Guide by Monica Pawlan 350 East Plumeria Drive San Jose, CA 95134 USA May 2013 Part Number TBD v1.0 Sun Microsystems. Inc. All rights reserved If
More informationACT Math Facts & Formulas
Numbers, Sequences, Factors Integers:..., -3, -2, -1, 0, 1, 2, 3,... Rationals: fractions, tat is, anyting expressable as a ratio of integers Reals: integers plus rationals plus special numbers suc as
More informationPart 1 Expressions, Equations, and Inequalities: Simplifying and Solving
Section 7 Algebraic Manipulations and Solving Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving Before launching into the mathematics, let s take a moment to talk about the words
More informationComp 248 Introduction to Programming
Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been
More informationHere's the code for our first Applet which will display 'I love Java' as a message in a Web page
Create a Java Applet Those of you who purchased my latest book, Learn to Program with Java, know that in the book, we create a Java program designed to calculate grades for the English, Math and Science
More informationMathematics. (www.tiwariacademy.com : Focus on free Education) (Chapter 5) (Complex Numbers and Quadratic Equations) (Class XI)
( : Focus on free Education) Miscellaneous Exercise on chapter 5 Question 1: Evaluate: Answer 1: 1 ( : Focus on free Education) Question 2: For any two complex numbers z1 and z2, prove that Re (z1z2) =
More informationZero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P.
MATH 11011 FINDING REAL ZEROS KSU OF A POLYNOMIAL Definitions: Polynomial: is a function of the form P (x) = a n x n + a n 1 x n 1 + + a x + a 1 x + a 0. The numbers a n, a n 1,..., a 1, a 0 are called
More informationThis activity will guide you to create formulas and use some of the built-in math functions in EXCEL.
Purpose: This activity will guide you to create formulas and use some of the built-in math functions in EXCEL. The three goals of the spreadsheet are: Given a triangle with two out of three angles known,
More informationSession 6 Number Theory
Key Terms in This Session Session 6 Number Theory Previously Introduced counting numbers factor factor tree prime number New in This Session composite number greatest common factor least common multiple
More informationClasses and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]
More informationTRIGONOMETRY Compound & Double angle formulae
TRIGONOMETRY Compound & Double angle formulae In order to master this section you must first learn the formulae, even though they will be given to you on the matric formula sheet. We call these formulae
More informationAP Physics 1 Summer Assignment
AP Physics 1 Summer Assignment AP Physics 1 Summer Assignment Welcome to AP Physics 1. This course and the AP exam will be challenging. AP classes are taught as college courses not just college-level courses,
More informationCore Maths C2. Revision Notes
Core Maths C Revision Notes November 0 Core Maths C Algebra... Polnomials: +,,,.... Factorising... Long division... Remainder theorem... Factor theorem... 4 Choosing a suitable factor... 5 Cubic equations...
More informationJava Basics: Data Types, Variables, and Loops
Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables
More informationSOLVING TRIGONOMETRIC EQUATIONS
Mathematics Revision Guides Solving Trigonometric Equations Page 1 of 17 M.K. HOME TUITION Mathematics Revision Guides Level: AS / A Level AQA : C2 Edexcel: C2 OCR: C2 OCR MEI: C2 SOLVING TRIGONOMETRIC
More informationALGEBRA 2/TRIGONOMETRY
ALGEBRA /TRIGONOMETRY The University of the State of New York REGENTS HIGH SCHOOL EXAMINATION ALGEBRA /TRIGONOMETRY Thursday, January 9, 015 9:15 a.m to 1:15 p.m., only Student Name: School Name: The possession
More informationMATH 140 Lab 4: Probability and the Standard Normal Distribution
MATH 140 Lab 4: Probability and the Standard Normal Distribution Problem 1. Flipping a Coin Problem In this problem, we want to simualte the process of flipping a fair coin 1000 times. Note that the outcomes
More informationMATH 108 REVIEW TOPIC 10 Quadratic Equations. B. Solving Quadratics by Completing the Square
Math 108 T10-Review Topic 10 Page 1 MATH 108 REVIEW TOPIC 10 Quadratic Equations I. Finding Roots of a Quadratic Equation A. Factoring B. Quadratic Formula C. Taking Roots II. III. Guidelines for Finding
More informationInner Product Spaces
Math 571 Inner Product Spaces 1. Preliminaries An inner product space is a vector space V along with a function, called an inner product which associates each pair of vectors u, v with a scalar u, v, and
More informationQuick Reference ebook
This file is distributed FREE OF CHARGE by the publisher Quick Reference Handbooks and the author. Quick Reference ebook Click on Contents or Index in the left panel to locate a topic. The math facts listed
More informationCSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus
CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus 1. Purpose This assignment exercises how to write a peer-to-peer communicating program using non-blocking
More information1 Math Circle WARM UP
1 Math Circle WARM UP Questions to consider: Please rank the following events. Make your best guess as to what happened when. Moon Landing Apollo 13 Invention of the pocket calculator Invention of the
More informationSecond Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients. y + p(t) y + q(t) y = g(t), g(t) 0.
Second Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients We will now turn our attention to nonhomogeneous second order linear equations, equations with the standard
More informationCOMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
More informationSituation Analysis. Example! See your Industry Conditions Report for exact information. 1 Perceptual Map
Perceptual Map Situation Analysis The Situation Analysis will help your company understand current market conditions and how the industry will evolve over the next eight years. The analysis can be done
More informationAnswer Key for California State Standards: Algebra I
Algebra I: Symbolic reasoning and calculations with symbols are central in algebra. Through the study of algebra, a student develops an understanding of the symbolic language of mathematics and the sciences.
More information3.2. Solving quadratic equations. Introduction. Prerequisites. Learning Outcomes. Learning Style
Solving quadratic equations 3.2 Introduction A quadratic equation is one which can be written in the form ax 2 + bx + c = 0 where a, b and c are numbers and x is the unknown whose value(s) we wish to find.
More information