Exercise 7'18 PsuedoCode - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Exercise 7'18 PsuedoCode

Description:

start if statement. assign next seat if available. else. ask for alternate section ... int count = 0, count1 = 1, count2 = 6, i = 0; while (count 10) ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 10
Provided by: MHU27
Category:

less

Transcript and Presenter's Notes

Title: Exercise 7'18 PsuedoCode


1
Exercise 7.18PsuedoCode
  • Initialize variables, including array of 10
  • start while loop
  • prompt for seat section
  • start if statement
  • assign next seat if available
  • else
  • ask for alternate section
  • increment counts
  • end while
  • end program

2
Flowchart
3
Source Code
  • import javax.swing.
  • public class Airline
  • public static void main( String args )
  • int a 0,0,0,0,0,0,0,0,0,0
  • String temp
  • int section 0
  • int count 0, count1 1, count2 6, i 0
  • while (count lt 10)
  • temp JOptionPane.showInputDialog( "Enter 1
    for nonsmoking \n"
  • "Enter 2 for smoking")
  • section Integer.parseInt( temp )

4
  • String temp
  • int section 0
  • int count 0, count1 1, count2 6, i 0
  • while (count lt 10)
  • temp JOptionPane.showInputDialog( "Enter 1
    for nonsmoking \n"
  • "Enter 2 for smoking")
  • section Integer.parseInt( temp )
  • ai 1
  • if (section 1)
  • if (count1 lt 6)
  • JOptionPane.showMessageDialog( null,
  • "Section is nonsmoking. \n"
  • "Seat number is " count1)

5
  • else
  • temp JOptionPane.showInputDialog(
  • "Nonsmoking section full! \n"
  • "Enter 1 for smoking section. \n"
  • "Enter 2 for next available flight." )
  • section Integer.parseInt (temp)
  • if (section 1)
  • JOptionPane.showMessageDialog(null,
  • "Section is smoking. \n"
  • "Seat number is " count2)
  • count2
  • i
  • count
  • else
  • JOptionPane.showMessageDialog( null,
  • "Next flight leaves in 3 hours!" )

6
  • else
  • temp JOptionPane.showInputDialog(
  • "Smoking section full! \n"
  • "Enter 1 for nonsmoking section. \n"
  • "Enter 2 for next available flight." )
  • section Integer.parseInt (temp)
  • if (section 1)
  • JOptionPane.showMessageDialog(null,
  • "Section is smoking. \n"
  • "Seat number is " count1)
  • count1
  • i
  • count
  • else
  • JOptionPane.showMessageDialog( null,
  • "Next flight leaves in 3 hours!" )

7
Sample Output
8

9
Write a Comment
User Comments (0)
About PowerShow.com