java programming help!!!pleasee - testmy.net resource / tool
Home
Welcome, Guest. Please login or register.
Did you miss your activation email?

 



donations help testmy.net pay for the very high cost to run the site. Any amount is greatly appreciated.
Click to read why...

  spcr
    
News : angel Do you think your good enough to write news for testmy.net?  Shoot me a PM and you may be accepted to write for us, a title of nobility Smile October 11, 2008, 06:31:21 PM
testmy.net Broadband  |  Main Forum  |  HELP!  |  Programming and Website Help  |  Topic: java programming help!!!pleasee Advanced search
  0 Members and 1 Guest are viewing this topic. « previous next »
Pages 1 Go Down
Author
Topic: java programming help!!!pleasee  (Read 895 times)
jamaicarocks
TMN Friend
*
Offline Offline

Posts: 297


There's no place like 127.0.0.1 .


View Profile WWW
« on: November 11, 2007, 03:56:00 AM »

hey guys , I would like to read info from a file e.g
[inline]
10
999990 Gerry Boudens
$1000.00
999991 Jimmy Chow
$1500.00
[/inline]

it is a credit card program, so the user would input their name and the program searches for it, if found it should show their credit card number and balance.Also users are suppose to be able to call them to display individually as well as be able to change these values.


My code is below, any HELP would be greatly welcomed, even references that will help me.


Code:
import java.io.*;
import java.util.*;
import type.lib.*;
import java.lang.*;

public class MyFileReader{
 
   

  public static void main(String[]args)throws java.io.IOException
  {
    Scanner fileInput = new Scanner(new File("a2.txt"));
    //java.io.File file = new java.io.File("a2.txt");
     //Scanner fileInput = new Scanner(file);
    PrintStream output = System.out;
    Scanner input = new Scanner(System.in);
    int count = 0;
     String Quit = null;   
         
    //START OF MAIN MENU
   
    output.println("MAIN MENU");
    output.println("----------");
   
    output.println("1 - Make purchase");
    output.println("2 - Make payment");
    output.println("3 - Change credit limit");
    output.println("4 - View credit limit");
    output.println("5 - View credit card balance");
    output.println("6 - View credit record");
    output.println("7 - Output entire database");
   
   
    output.println("Quit -    Exit database");
   
   
    output.println("Enter the number refered to your selection: ");
   
    String inputs = input.nextLine();

     
    for (; !inputs.equals("Quit"); inputs = input.nextLine())
  {
     if     (inputs.equals("1"))
     {
             output.println ("Enter full name of the card holder");
             String chname = input.next();
         
             
       for  (; fileInput.hasNext() ;)
      {     String temp2 = fileInput.next().toLowerCase();
            String temp = chname.toLowerCase();
       
       if  (temp.equals(temp2))
         {  output.println("Enter Purchase amount: "  );
           
         }
     
      }//close of for name on file         
           
           fileInput.close();
           output.println("Name not in Database: "  ); 
     }//close of if choose 1
       
      if   (inputs.equals("7"))
     {
        for (; fileInput.hasNext() ;)
         {
     
         String temp2 = fileInput.next();
           
          output.println(temp2);
          }
       
     }//close of if choose 7
     
     
           
   }// main for statement
   
         
   
   
    fileInput.close();
   
    }
   
  }
import java.io.*;
import java.util.*;
import type.lib.*;
import java.lang.*;

public class MyFileReader{
 
   

  public static void main(String[]args)throws java.io.IOException
  {
    Scanner fileInput = new Scanner(new File("a2.txt"));
    //java.io.File file = new java.io.File("a2.txt");
     //Scanner fileInput = new Scanner(file);
    PrintStream output = System.out;
    Scanner input = new Scanner(System.in);
    int count = 0;
     String Quit = null;   
         
    //START OF MAIN MENU
   
    output.println("MAIN MENU");
    output.println("----------");
   
    output.println("1 - Make purchase");
    output.println("2 - Make payment");
    output.println("3 - Change credit limit");
    output.println("4 - View credit limit");
    output.println("5 - View credit card balance");
    output.println("6 - View credit record");
    output.println("7 - Output entire database");
   
   
    output.println("Quit -    Exit database");
   
   
    output.println("Enter the number refered to your selection: ");
   
    String inputs = input.nextLine();

     
    for (; !inputs.equals("Quit"); inputs = input.nextLine())
  {
     if     (inputs.equals("1"))
     {
             output.println ("Enter full name of the card holder");
             String chname = input.next();
         
             
       for  (; fileInput.hasNext() ;)
      {     String temp2 = fileInput.next().toLowerCase();
            String temp = chname.toLowerCase();
       
       if  (temp.equals(temp2))
         {  output.println("Enter Purchase amount: "  );
           
         }
     
      }//close of for name on file         
           
           fileInput.close();
           output.println("Name not in Database: "  ); 
     }//close of if choose 1
       
      if   (inputs.equals("7"))
     {
        for (; fileInput.hasNext() ;)
         {
     
         String temp2 = fileInput.next();
           
          output.println(temp2);
          }
       
     }//close of if choose 7
     
     
           
   }// main for statement
   
         
   
   
    fileInput.close();
   
    }
   
  }

also: if I enter a name to be searched in the file, it only recognises the first name:
Logged

Image and video hosting by TinyPic
Print  Pages 1 Go Up
testmy.net Broadband  |  Main Forum  |  HELP!  |  Programming and Website Help  |  Topic: java programming help!!!pleasee « previous next »
Jump to:  

    
testmy.net's forum is proudly Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Bookmark: Del.icio.us    StumbleUpon
 
 

 

© 1999-2008 testmy.net - Contact - Legal - Facts & FAQs
Page Loading Stats: This forum Page created in 0.087 seconds with 25 queries.