Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will read a file containing information about clients: name

ID: 3653133 • Letter: W

Question

Write a program that will read a file containing information about clients: names, passwords, account balances and ID numbers. The information will be stored in a table. The table will be printed and some statistics will be computed. In particular, this program will make use of internal subroutines, character data and packed decimal numbers. Input The input to the program will be a file with an unknown number of records. Each record represents a single client of Famous Names, Inc. and has the following format: columns description ------- ----------- 1 - 10 First Name (characters) 11 not used (period) 12 - 21 Last Name (characters) 22 not used (period) 23 - 30 Password (characters) 31 not used (period) 32 - 40 ID Number (characters) 41 not used (period) 42 - 48 Balance (numeric, a number of pennies) 49 Sign of the balance (+ or -) 50 not used (period) 51 - 58 Expiration Date (Year, Month, Day) 59 - 80 not used (blanks) A positive balance indicates that the client owes us money, and a negative balance indicates that we owe the client money. Use the following JCL statement to specify the input file: //FT05F001 DD DSN=KC02314.AUTUMN12.CSCI360.HW6DATA,DISP=SHR Processing Requirements The main program will carry out the following steps: Call subroutine BUILD to read the file and store the data in a table. BUILD needs two parameters: the address of the table and the address of a fullword containing the address of the first unused entry. Call subroutine PRINT to print the contents of the table, using appropriate page and column headings. PRINT needs the same two parameters as BUILD. Call subroutine TALLY to compute and print the number of clients, the sum of all account balances, the average account balance, the largest account balance and the number of negative account balances. These can be added at the end of the last page. Other Notes You may assume that the table needs to hold no more than 70 values. Each entry should have the following format: First Name (10 characters) Last Name (10 characters) Balance (5 packed decimal bytes) Password (8 characters) Expiration Date (5 packed decimal bytes) ID Number (9 characters) Filler (1 blank) When you read in the sign of the balance, you will need to test whether it is '-' and adjust the sign of the Balance value accordingly. (Maybe multiply by =P'-1'.) As you work on this, you may need to XDUMP all or part of the table to check your work. Each line of XDUMP prints 32 bytes of data, starting on a 16-byte boundary, and each table entry is 48 bytes long. Use the following ORG trick to line up your table on a 16-byte boundary: ORG PROG6+((*-PROG6+15)/16)*16 TABLE DS 70CL48 (This assumes your program's name is PROG6.) You may find it necessary to declare the table near the end of the file because of the 4096-byte limit on the range of the USING statement. As long as the beginning of the table is within the 4096-byte range, you should not have a problem. Write this program incrementally, one subroutine at a time. Start with BUILD and XDUMP the table to see whether BUILD is correct. After that, write and test PRINT. Once you have PRINT working, you can go on to TALLY. The JCL for this assignment is the same as the JCL used in Assignments 4 and 5 except for the line given above to provide the data. You may not use XDECI or XDECO anywhere in this assignment. The numbers should all be stored in packed decimal format. When you print amounts of money, print a leading dollar sign, a decimal point and two digits to the right of the decimal point. If an amount of money is negative, print CR to the right of the value. When you print a date, print it in the format 2012/11/30. Output The page header for the report should start at the top of a new page. The page heading should be centered. The column headers should be double-spaced from the page header. The lines of client information should be double spaced. The summary lines should be triple-spaced from the last client record. Print no more than 20 lines of client information per page. *I'm having trouble using internal subroutines. In general assembler is challenging in the fact that the UI is dated and the instructor isn't the best isn't really helping me. My next assignment depends on this one working properly.

Explanation / Answer

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class login extends JFrame { // Variables declaration private JLabel jLabel1; private JLabel jLabel2; private JTextField jTextField1; private JPasswordField jPasswordField1; private JButton jButton1; private JPanel contentPane; // End of variables declaration public login() { super(); create(); this.setVisible(true); } private void create() { jLabel1 = new JLabel(); jLabel2 = new JLabel(); jTextField1 = new JTextField(); jPasswordField1 = new JPasswordField(); jButton1 = new JButton(); contentPane = (JPanel)this.getContentPane(); // // jLabel1 // jLabel1.setHorizontalAlignment(SwingConstants.LEFT); jLabel1.setForeground(new Color(0, 0, 255)); jLabel1.setText("username:"); // // jLabel2 // jLabel2.setHorizontalAlignment(SwingConstants.LEFT); jLabel2.setForeground(new Color(0, 0, 255)); jLabel2.setText("password:"); // // jTextField1 // jTextField1.setForeground(new Color(0, 0, 255)); jTextField1.setSelectedTextColor(new Color(0, 0, 255)); jTextField1.setToolTipText("Enter your username"); jTextField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField1_actionPerformed(e); } }); // // jPasswordField1 // jPasswordField1.setForeground(new Color(0, 0, 255)); jPasswordField1.setToolTipText("Enter your password"); jPasswordField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jPasswordField1_actionPerformed(e); } }); // // jButton1 // jButton1.setBackground(new Color(204, 204, 204)); jButton1.setForeground(new Color(0, 0, 255)); jButton1.setText("Login"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); // // contentPane // contentPane.setLayout(null); contentPane.setBorder(BorderFactory.createEtchedBorder()); contentPane.setBackground(new Color(204, 204, 204)); addComponent(contentPane, jLabel1, 5,10,106,18); addComponent(contentPane, jLabel2, 5,47,97,18); addComponent(contentPane, jTextField1, 110,10,183,22); addComponent(contentPane, jPasswordField1, 110,45,183,22); addComponent(contentPane, jButton1, 150,75,83,28); // // login // this.setTitle("Login To Members Area"); this.setLocation(new Point(76, 182)); this.setSize(new Dimension(335, 141)); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setResizable(false); } /** Add Component Without a Layout Manager (Absolute Positioning) */ private void addComponent(Container container,Component c,int x,int y,int width,int height) { c.setBounds(x,y,width,height); container.add(c); } private void jTextField1_actionPerformed(ActionEvent e) { } private void jPasswordField1_actionPerformed(ActionEvent e) { } private void jButton1_actionPerformed(ActionEvent e) { System.out.println(" jButton1_actionPerformed(ActionEvent e) called."); String username = new String(jTextField1.getText()); String password = new String(jPasswordField1.getText()); if(username.equals("") || password.equals("")) // If password and username is empty > Do this >>> { jButton1.setEnabled(false); JLabel errorFields = new JLabel("You must enter a username and password to login."); JOptionPane.showMessageDialog(null,errorFields); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); this.setVisible(true); } else { JLabel optionLabel = new JLabel("You entered "+username+" as your username.
Is this correct?"); int confirm =JOptionPane.showConfirmDialog(null,optionLabel); switch(confirm){ // Switch > Case case JOptionPane.YES_OPTION: // Attempt to Login user jButton1.setEnabled(false); // Set button enable to false to prevent 2 login attempts break; case JOptionPane.NO_OPTION: // No Case.(Go back. Set text to 0) jButton1.setEnabled(false); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); break; case JOptionPane.CANCEL_OPTION: // Cancel Case.(Go back. Set text to 0) jButton1.setEnabled(false); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); break; } // End Switch > Case } } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { System.out.println("Failed loading L&F: "); System.out.println(ex); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote