Jump to content
jamaicarocks

java programming help!!!pleasee

Recommended Posts

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.

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();

    

    }

    

  }

[/code]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
Speed Test Version 15.9
© 2019 TestMy Net LLC - TestMy.net - Terms & Privacy