You are on page 1of 24

Module 1 Using BlueJ

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
1
The Programming Process
1. Clearly define what the program is to do.
1. xx
2. Visualize the program running on the computer.
2. xx
3. Use design tools to create a model of the program
3. xx
4. Establish a xx
– manually determine the output based on a specific set of input values

1-2 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
The Programming Process
5. xx and compile it.
6. Correct any xx found during compilation.
Repeat Steps 5 and 6 as many times as necessary.
7. Run the program with test data for input.
8. Correct any xx found while running the program.
• Repeat Steps 5 through 8 as many times as necessary.

9. xx the program by running it against the test plan


– correct any xx, repeat steps 5-9 as necessary

1-3 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Flowcharts
 Used to explain how to solve the problem
using a xx
 Includes statement that explain:
– What value to input and store in variables
– The flow of control to use while solving the
problem
– How to calculate results using variables and
constants
– What to output

1-4 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Standard Flowchart Symbols
 TERMINAL - To start or end a flowchart

 INPUT / OUTPUT - Used to when information is fed into the computer or


information comes out of the computer. ( Used with Read, Input, Print and
other I/O commands).

 
 PROCESSING - Used for operations done inside the computer. Such as
calculations, storing and moving of data. (Formulas calculations and the Let
statement).

 DECISION - Used to ask a question in programming. Questions are Yes/No


format. Solutions for both sides must be shown and completed. (Used with the
If Statement).

 DIRECTION FLOW - Used to connect symbols and to represent the direction


of flow. Lines should not cross each other. Arrowheads should be placed at the
end close to the symbol.

 CONNECTOR - Represents an entry from or an exit to another part of the


flowchart. Connector identification should be placed within the symbol. Use a
letter or a number.

 OFF PAGE CONNECTOR - Used when a flowchart is continued on a different


page. Use a letter or a number to identify or match the symbols.

1-5 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Common Arithmetic and Relational Symbols

Symbol Symbol
+, plus, add <=, less than or equal to
-, subtract, minor !=, not equal to
*, multiple, product T, True
/, divide F, False
==, equal to Yes
>, greater than No
<, less than Start
>=, greater than or equal to End
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
1-6
Flowcharting Rules
1. Use only one enter point and one exit point.
2. The logic flow of the solution is displayed from
top to bottom and from left to right.
3. Use the appropriate symbol for each type of
operation.
4. Use connectors when moving to another part of
the flowchart rather than lines.
5. Questions in flowcharts are asked in a yes/no
format. Complete both the yes side and the no side
for each question asked in the flowchart.
6. Do not leave dead-ends--that is, a part of a
question unanswered.

1-7 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Pseudocode
• Cross between human language and programming
language
• Used to explain how to solve the problem from the
computer’s point of view
• Includes statements that explain:
– What value to input and store in variables
• xx
– The flow of control to use while solving the problem
– How to calculate results using variables and constants
• xx
– What to output
• xx

1-8 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Test Plan
 Programmer identifies a way to verifying
the correct operation of the program
BEFORE the program is ever written
 Often done by specifying a table of input
values, expected output values and leaving
a column for the actual program results

1-9 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
But how do we do this
on the computer?

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
10 rights reserved.
Using BlueJ
 Editing, compiling and run on command line
gives a true view of all of the components
needed to develop java program
 Command line processing is:
– Tedious
– Error-prone
 To reduce overhead IDE (Integrated
Development Environment) were created

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
11 rights reserved.
IDEs
 There are many IDEs for Java
– Microsoft .NET
– jGrasp
– jCreator
– Eclipse
– BlueJ
– NetBeans
 We will use BlueJ

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-12 rights reserved.
Some IDEs are very complex

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-13 rights reserved.
Using BlueJ
 An Full featured IDE
– Text editor (context sensitive editing)
– Accesses java compiler and JVM
– Output Window
– Full feature Debugger
– Help file system
– Easy to use!

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-14 rights reserved.
Configuring BlueJ
Configuring BlueJ on a Windows Machine
1.Download and Install for Windows 7 or later, includes JDK
(~232 MB) MSI (Windows Installer Package)
– [x] install for all users
– Click [Next] under you finish the install.
2.Replace the standard class template file in BlueJ
– From Module 1 content in Brightspace, download 'stdclass.tmpl' and
save it to your desktop
– Drag and drop ‘stdclass.tmpl’ from your desktop to:
C:\Program Files\BlueJ\lib\english\templates\newclass
3.Start BlueJ

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-15 rights reserved.
Steps to using BlueJ
1. Create project
– File -> New Project
 Create a Module 1 project under c:\cmpp269s\
2. Create Class to hold source code
– New Class
 Class Name : filename
3. Type in java code
4. Compile Program
– In editor window using [Compile] button
5. Fix errors
6. Run program
– Go to New BlueJ window
– Right-click on Class and select [void main (String [] args)]
– Press [OK] when Method class dialog is presented
7. View results in Terminal Window
8. Copy results from Terminal Window and paste into Notepad to save and submit

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-16 rights reserved.
Accessing the Java Class Library
Help

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-17 rights reserved.
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
1-18 rights reserved.
Lab Mod 1: Available Credit
Write a program to calculate Available Credit
A program that calculates a customer’s available
credit should ask the user for the following:
– the customer’s credit limit
– the current amount owing
Once these items have been entered the program
should calculate and display the available
credit.

1-19 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Lab Mod 1: Start

Available print “Enter limit”

Credit Input limit

print “Enter owing”

Input owing

Available = limit - owing

Print “Credit available is” + available

End
1-20 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Lab Mod 1: Available Credit
Psuedocode
xx

1-21 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Lab Mod 1: Available Credit Test Plan
Input Values Expected Output

Limit: 800 The amount


Owing: 400 available is $400

Limit: 1100 The amount


Owing: 1100 available is $0

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
1-22
Lab Mod 1: Available Credit
Source Code
import java.util.Scanner;
public class Available
{
public static void main (String args[])
{
double limit, owing, available;
Scanner k = new Scanner (System.in);

System.out.print ("Enter credit limit: ");


limit = k.nextDouble();
System.out.print ("Enter amount owing: ");
owing = k.nextDouble();
available = limit - owing;
System.out.println ("Credit available is $" + available);
}
}

1-23 Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
rights reserved.
Lab Mod 1: Available Credit
 Submission requirements
– source code
– sample run that MATCHES the test plan

Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All
24 rights reserved.

You might also like