Flow Chart - PowerPoint PPT Presentation

Loading...

PPT – Flow Chart PowerPoint presentation | free to view - id: 21afdd-NmIzO



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Flow Chart

Description:

draw the results with g.drawString. g.drawRect( 15, 10, 270, 20 ); g.drawString (result, 25, 25 ) ... g.drawString ( result, 25, 25 ); Flow Chart. Start. Enter ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 13
Provided by: annp7
Category:
Tags: chart | drawstring | flow

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Flow Chart


1
Flow Chart
Start
2nd Number gt 1st Number?
Display Message 2nd Number is greater than 1st
Number
Enter 1st Number
1st number gt 2nd number?
Display Message 1st Number is greater than 2nd
Number
Enter 2nd Number
Read 2nd Number
Equal?
Read 1st Number
Stop
Display Message These numbers are equal
2
Pseudo Code
the Comparision between two numbers or value and
determine if they are equal Initialize
variables Enter 1st number Enter 2nd number Read
1st number Read 2nd number If 1st number 2nd
number Display These numbers are equal Else
Display 1st number is greater than 2nd
number Else Display 2nd number is greater than
1st number
3
Source Code
// ComparisionApplet.java // Comparing two
floatin/g-point numbers import java.awt.Graphics
// import class Graphics import javax.swing.
// import package javax.swing public class
ComparisionApplet extends JApplet double sum
// sum of the values entered by the user
public void init () String firstNumber,
// first string is entered by user
secondNumber, // second string is entered by
user result // a string
containing the output double number1,
// first number to compare number2
// second number to compare
4
Source Code cont.
// read in first number from user firstNumber
JOptionPane.showInputDialog( "Enter
first floating-point value" ) // read in
second number from user secondNumber
JOptionPane.showInputDialog( "Enter second
floating-point value" ) // convert numbers
from type String to type int number1
Double.parseDouble( firstNumber ) number2
Double.parseDouble( secondNumber )
5
Source Code cont.
// initialize result to the empty string
result "" if (number1 number2)
result (result "These numbers are equal")
if (number1 lt number2) result (number1
"is larger than" number2) if (number1 gt
number2) result (number2 "is larger
than" number1) public void paint
(Graphics g)
6
Source Code cont.
//draw the results with g.drawString
g.drawRect( 15, 10, 270, 20 ) g.drawString
(result, 25, 25 ) g.drawRect ( 15, 10,
270, 20 ) g.drawString (result, 25, 25
) g.drawRect( 15, 10, 270, 20 )
g.drawString ( result, 25, 25 )
7
Flow Chart
Enter Account Number
Enter Total Charges
Enter Account Balance
Enter Total Credits
Start
Enter Account Credit Limit
Display New Balance
No
Stop
New Balance Exceed Credit Limit?
Calculate New Balance
Display Exceed Credit Limit
yes
8
Pseudocode
  • Calculate account balance and determine if new
    balance exceeds the credit limit
  • Initialize variables
  • Enter account number
  • Enter beginning account balance
  • Enter total charges for the month
  • Enter total credits for the month
  • Enter account credit limit
  • Calculate new balance
  • New balance beginning balance charges -
    credits
  • If new balance exceeds credit limit
  • Display Exceeds credit limit
  • Else
  • Display New balance

9
Source Code
  • // Exercise 4.12 Credit.java
  • // Determine credt of customer.
  • import javax.swing.
  • public class Credit
  • public static void main (String args )
  • // initializing variables in calculation
  • String accountNumber, // account number
    entered by user
  • accountBalance, // balance entered
    by user
  • totalCharges, // total charges
    entered by user
  • totalCredits, // total credits
    entered by user
  • creditLimit, // allowed credit
    limit entered by user
  • result // a string
    containing the output
  • int balance, // beginning balance
    to be added or subtracted from
  • charges, // total charges to
    add
  • credits, // total credits to
    subtract
  • newBalance, // beginning balance
    charges - credits

10
  • // read in account number from user as a string
  • accountNumber
  • JOptionPane.showInputDialog( "Enter
    account number" )
  • // read in balance from user as a string
  • accountBalance
  • JOptionPane.showInputDialog ( "Enter
    account balance" )
  • // read in total charges for the month from
    user as a string
  • totalCharges
  • JOptionPane.showInputDialog ( "Enter
    total charges" )
  • // read in total credits for the month from
    user as a string
  • totalCredits
  • JOptionPane.showInputDialog ( "Enter
    total credits" )
  • // read in allowed credit limit for account
    from user as a string
  • creditLimit
  • JOptionPane.showInputDialog ( "Enter
    credit limit" )

11
  • // convert numbers from string to type int
  • balance Integer.parseInt (
    accountBalance )
  • charges Integer.parseInt (
    totalCharges )
  • credits Integer.parseInt (
    totalCredits )
  • limit Integer.parseInt (
    creditLimit )
  • // initialize result to the empty string
  • result ""
  • // calculate new balance
  • newBalance balance charges - credits
  • if (newBalance gt limit)
  • result result newBalance "Credit
    limit exceeded"
  • // display the new balance
  • JOptionPane.showMessageDialog (
  • null, "New balance is" newBalance, "New
    Balance",
  • JOptionPane.PLAIN_MESSAGE )

12
  • // if new balance exceeds credit limit
  • JOptionPane.showMessageDialog(
  • null, result "Credit limit exceeded",
    "New Balance",
  • JOptionPane.PLAIN_MESSAGE )
  • System.exit ( 0 )
About PowerShow.com