Homework 7 Code

Homework 7 Code - file:///X|/cs101/Homework7.txt /* 3...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: file:///X|/cs101/Homework7.txt /* 3 functions: open new account, perform account transaction, quit. */ import java.util.Scanner; public class Homework7 { public static void main(String args) { Scanner input = new Scanner(System.in); String buffer; double doubleBuffer; int txnAccount; int printCount; final int ACCOUNT_MAGIC_NUMBER = 578; int ACCOUNT_MODIFIER = 0; String accountName = new String[2]; String accountAddr = new String[2]; String accountPNmb = new String[2]; double accountCBal = new double[2]; String accountTRcd = new String[2][3]; do { // print the available choices. System.out.println("\nPlease make a choice:\n" +" (o) open new account\n" +" (t) perform account transaction\n" +" (q) quit"); // prompt until we get proper input. do { System.out.print("> "); buffer = input.nextLine(); } while(!(buffer.equals("o") || buffer.equals("t") || buffer.equals("q"))); // quit. if (buffer.equals("q")) break; // open a new account. else if (buffer.equals("o")) { System.out.println(); // get name. do { System.out.print("Customer name: "); buffer = input.nextLine(); if (buffer.matches("\\w+ \\w+")) break; } while(true); accountName[ACCOUNT_MODIFIER] = buffer; // get address. System.out.print("Customer address: "); buffer = input.nextLine(); accountAddr[ACCOUNT_MODIFIER] = buffer; // get phone number. do { System.out.print("Customer phone number (xxx-xxx-xxxx): "); file:///X|/cs101/Homework7.txt (1 of 5) [4/29/2008 12:11:09 PM] file:///X|/cs101/Homework7.txt buffer = input.nextLine(); if (buffer.matches("\\d{3}-\\d{3}-\\d{4}")) break; } while(true); accountPNmb[ACCOUNT_MODIFIER] = buffer; // get initial balance....
View Full Document

This note was uploaded on 04/29/2008 for the course CS 101L taught by Professor Vineyard during the Winter '07 term at Kettering.

Page1 / 5

Homework 7 Code - file:///X|/cs101/Homework7.txt /* 3...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online