Payroll Program - please help

I have a Java assignment due this Sunday, and I'm lost. I'm completely new to Java and this is only the second thing I've tried so far, so bear with me please, and don't laugh. :)
This is the assignment:
+"Create a non-GUI based Java application that calculates weekly pay for an+
+employee. The application should display text that requests the user input the name+
+of the employee, the hourly rate, and the number of hours worked for that week. The+
+application should then print out the name of the employee and the weekly pay+
+amount. In the printout, display the dollar symbol ($) to the left of the weekly pay+
+amount and format the weekly pay amount to display currency."+
In my chapter it talks about how to write a program that adds integers, so I tried to emulate that example but instead make it multiply. I wasn't sure how to do the employee's name, there is an explanation on printing lines of text, but not inputing and displaying text, only numbers. So for the employee's name I did some guesswork (for the data type declaration, etc), so I have no idea if that's right, (or if any of this is for that matter). I also don't know how to make it display the dollar symbol.
Here is what I did so far:
// Payroll Program Part 1
import java.util.Scanner; // program uses class Scanner
public class Multiplication
   // main method begins execution of Java application
   public static void main( String args[] )
      // create Scanner to obtain input from command window
      Scanner input = new Scanner( System.in );
      String name; // employee name to display
      int number1; // first number to multiply
      int number2; // second number to multiply
      int product; // product of number1 and number2
      System.out.print( "Enter employee name: "); // prompt
      name = input.nextString (); // read employee name from user
      System.out.print( "Enter hourly rate: " ); // prompt
      number1 = input.nextInt(); // read first number from user
      System.out.print( "Enter hours worked: " ); // prompt
      number2 = input.nextInt(); // read second number from user
      product = number1 * number2; // multiply numbers
      System.out.println( "Employee \n", name): // display employee name
      System.out.printf( "Weekly pay is %d\n", product ); // display product
   } // end method main
} // end class MultiplicationKnow that I'm not asking anyone to do my homework for me, I just need some direction. I don't know what I'm doing, my teacher isn't helping and I'm not getting anything out of my chapters. Any assistance would be appreciated.

newark wrote:
You don't know how to print the $ symbol? Your code shows that you know how to print with System.out.println()...all that's left is finding the $ symbol on the keyboard...
So what exactly is your problem? You say you don't know if your code is right. I have a suggestion...*run* your code and see if it works. If it works, it's right. If not, then come back here and let us know what it does do, including any exact error messages you might get.It's not easy to detect sarcasm over the Internet. Seriously I didn't think it would be that simple, but I just added the symbol, so now it says +"Weekly pay is $%d\n"+
I don't know if that's in there right.
Also, I tried to compile the program, and it found four errors, I fixed a couple (changed : to ; and apparently the public class name has to be the same as the file name, so now its public class Payroll1), but there are two others mistakes I made, both of which were my attempt at trying to include the program request the input and display the output for the employee name.
They are both "cannot find symbol" errors, the first one is input.*nextString ()*; and the second is System.out.*println*
So my guess at replacing int with "String" was wrong, and println is wrong. I'm going to try something else.

Similar Messages

  • My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.

    My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.
    I have checked the cooling fan, and it's working, and I took it to an IT technician and he said my hardware is allright, so is it a problem from the OS it self??
    OS X(10.8.5)

    Restart with the Option key held down and the Mac OS X install disk inserted, provide the firmware password, click on the DVD, press the button with the straight arrow, access the firmware settings, disable the password, and use FireWire Target Disk mode. If you can't do that or it doesn't work, contact Apple.
    (38384)

  • I have windows 8 and I got this error "Adobe Photoshop has stopped working" whenever I start a program. please help. how can I fix this problem? many thanks

    i have windows 8 and I got this error "Adobe Photoshop has stopped working" whenever I start a program. please help. how can I fix this problem? many thanks

    Please read these and proceed accordingly:
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    http://forums.adobe.com/docs/DOC-2325

  • Error while running HelloWorld program Please Help me

    Hi Friends! I am doing my hello world program...while running i m getting the below error...please help me regarding this...
    The target WSCO.java cannot be started as a servlet, because the class oracle.apps.ak.ws.webui.WSCO does not extend javax.servlet.GenericServlet.
    The target WSCO.java cannot be started as an application, because the class oracle.apps.ak.ws.webui.WSCO does not have a main method.

    Hi,
    For building a simple hello world page, follow these steps:
    1) Create a New OA Workspace and a new OA Project. Make sure that package name should be prefixed by some custom name like:
    xx.oracle.apps.ak.hello
    2) Create new OA Page under webui:
    xx.oracle.apps.ak.hello.webui.XxHelloWorldPG
    3) Create a new Application module, XxHelloWorldAM in below package:
    xx.oracle.apps.ak.hello.server.XxHelloWorldAM
    4) Attach this AM to your XxHelloWorldPG.
    5) Now create regions and items under pageLayout region of this page.
    6) Add a controller to pageLayout region in webui package:
    xx.oracle.apps.ak.hello.webui.XxHelloWorldCO
    Also you can add a button on the page and write some code in PFR method of your controller.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem compiling my first program; Please Help me!

    Please HELP, what am I doing wrong?
    For over 5hours I have been trying to figure out how to compile a simple Hello world program using sdk1.3.1_02/j2re1.3.1_02 and I am getting the following errors: helloworld.java:2 cannot resolve symbol
    symbol : class string
    location : class helloworld
    cannot reolve the string symbol
    symbol : class out
    location : package system
    I want to program in java so badly but I am trying to get my environment set so that I can take off. To compile my first program has been a disaster!!
    This is my path:
    SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.3.1_02\BIN
    Thanks very much in advance
    ::(

    Java is case sensitive,
    use String instead of string. and System.out instead of system.out
    Sudha

  • I paid for membership and cannot access the program please help???????

    I paid for the program and cannot access it please help may i talk to someone?

    Did you install the trial or any update version?
    What were the instructions when you purchased?

  • Connecting two programs - please help

    Hi, I'm new here, so I'd like to say 'hi' to everyone :) I'm a freshman in the java comunity, so please be gentle.
    Firs of all I'd like to ask how to resolve the first problem. I've got the code which is responsible for convert a html document to the txt file. It looks like:
    import javax.swing.text.html.parser.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import javax.swing.*;
    import java.io.*;
    public class TextFromHtml extends HTMLEditorKit.ParserCallback{
    static String trimmss(String o){
       return (o.trim()).replaceAll("\\s+", " ");
    public void handleText(char[] data, int pos){
    try{
          String o = new String(data);
          PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.txt", true)));
          o = trimmss(o);
          pw.println(o);
          //pw.close();
         catch (IOException exc){}      
    System.out.println(new String(data));
      public static void main(String args[]){
        try{
          String s = JOptionPane.showInputDialog("Enter the name of the file you want to convert from html to txt.");     
          Reader r = new FileReader(s);
          ParserDelegator parser = new ParserDelegator();
          HTMLEditorKit.ParserCallback callback = new TextFromHtml();
          parser.parse(r, callback, true); 
        catch (IOException e){
          e.printStackTrace();
         System.exit(0);
    }But unfortunately I don't know how to change this code to obtain such situation as making a new txt file without blank spaces > 0 and erasing the \n new lines. I'd like to get a txt file, which contains of line-by-line text. Could you please help me - tell & show me how to do that? I'd be very grateful
    Regards, skullscape.

    Hi Skullscape,
    My apologies for not getting a response on this forum, but this may have been because this is a fairly generic Java programming question, rather than an issue specific to the JSE product, the purpose of this particular forum.
    So may I suggest that you check out http://java.sun.com/ which has a full set of facilities for those such as yourself who are new to Java programming.
    Although by now you nay not be such a novice :-)

  • Deleted apple mail program, please help!

    I deleted mail, and can't seem to find it within the 'install bundled software' on the discs which came with the computer (mac os x install discs 1 & 2). How can I go about reinstalling the program? Please Help...

    Hi Rob, and a warm welcome to the forums!
    Is that the Install Disk?
    Custom installs in Mac OS X 10.4...
    http://docs.info.apple.com/article.html?artnum=301229
    "Here's a list of all the custom installation options available with Optional Installs.mpkg:
    * Applications
    o Address Book 4.0
    o iCal 2.0
    o iChat 3.0
    o iTunes 4.7.1
    o Mail 2.0
    o Oxford Dictionaries
    o Safari 2.0
    o X11"
    If that isn't the case, get Pacifist...
    http://www.charlessoft.com/
    then extract what you need from your Install Disk.

  • Problem with simple drawing program - please help!

    Hi,
    I've only just started using Java and would appreciate some help with a drawing tool application I'm currently trying to write.
    The problem is that when the user clicks on a button at the bottom of the frame, they are then supposed to be able to produce a square or circle by simply clicking on the canvas.
    Unfortunately, this is not currently happening.
    Please help!
    The code for both classes is as follows:
    1. DrawToolFrame Class:
    import java.awt.*;
    import java.awt.event.*;
    public class DrawToolFrame extends Frame
    implements WindowListener
    DrawToolCanvas myCanvas;
    public DrawToolFrame()
    setTitle("Draw Tool Frame");
    addWindowListener(this);
    Button square, circle;
    Panel myPanel = new Panel();
    square = new Button("square"); square.setActionCommand("square");
    circle = new Button("circle"); circle.setActionCommand("circle");
    myPanel.add(square); myPanel.add(circle);
    add("South", myPanel);
    DrawToolCanvas myCanvas = new DrawToolCanvas();
    add("Center", myCanvas);
    square.addMouseListener(myCanvas);
    circle.addMouseListener(myCanvas);
    public void windowClosing(WindowEvent event) { System.exit(0); }
    public void windowOpened(WindowEvent event) {}
    public void windowIconified(WindowEvent event) {}
    public void windowDeiconified(WindowEvent event) {}
    public void windowClosed(WindowEvent event) {}
    public void windowActivated(WindowEvent event) {}
    public void windowDeactivated(WindowEvent event) {}
    2. DrawToolCanvas Class:
    import java.awt.*;
    import java.awt.event.*;
    public class DrawToolCanvas
    extends Canvas
    implements MouseListener, ActionListener {
    String drawType="square";
    Point lastClickPoint=null;
    public void drawComponent(Graphics g) {
    if (lastClickPoint==null) {
    g.drawString("Click canvas first",20,20);
    } else {
    if (drawType.equals("square")) {
    square(g);
    else if (drawType.equals("circle")) {
    circle(g);
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("square"))
    drawType="square";
    else if (event.getActionCommand().equals("circle"))
    drawType="circle";
    repaint();
    public void mouseReleased(MouseEvent e) {
    lastClickPoint=e.getPoint();
    public void square(Graphics g) {
    g.setColor(Color.red);
    g.fillRect(lastClickPoint.x, lastClickPoint.y, 40, 40);
    g.setColor(Color.black);
    public void circle(Graphics g) {
    g.setColor(Color.blue);
    g.fillOval(lastClickPoint.x, lastClickPoint.y, 40, 40);
    g.setColor(Color.black);
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseClicked(MouseEvent e) {}
    Any help would be appreciated!

    Some of the problems:
    1) nothing calls drawComponent(Graphics g)
    2) Paint(Graphics g) has not been overriden
    3) myCanvas is declared twice: once as an instance variable to DrawToolFrame, and once local its constructor. Harmless but distracting.

  • HT6114 hi all, my cisco Router link sys E2000 stop working need to up date Mac OS 10.4.9 or 10.5.8 or 10.6.1later how do i find this program please help

    hi all, my cisco router linksys E2000 stop working need to up date Mac OS 10.5.8 later or 10.5.8 or later or 10.6.1 or later where do i find this up date im new on mac computer please help

    I just visited the Linksys e2000 page, I think you need 10.6. You can buy it here:
    http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard

  • Can't Install Windows Program -PLEASE HELP

    This is now my 3rd attempt at trying to install stupid Windows on my Mac (need for merchant account and quickbooks).
    Anyway, I ordered Microsoft XP 2000 Home OEM. I actually go a link from a person on this board. I am a little concerned because the packaging and CD says 'to be distributed with a new PC'. It has been my problem that I have been using Free software and it won't take the Free version.
    Okay, here is what I have done so far
    1. Partitioned HD for Windows in Bootcamp
    2. Inserted new Windows CD
    3. Screen goes White(ish) and you here the Windows (bong).
    4. CD ejects
    5. Screen goes black and then you get a message that says 'no bootable device insert boot disk press any key)
    6. Reinsert CD, nothing happens
    Concern is there is some old Windows on this when I have tried to download in the past. I however cannot find anywhere and believe that I ahve removed everything. I did download a trial version of Parallels and tried to download another Windows version, but I removed everything from my computer that had to do with Paralles (or so I thought...even emptied trash).
    So, I am DESPERATE!! PLEASE HELP
    5. Insert

    Here is where I am now...
    I was able to remove Windows from Bootcamp.
    I go through the set up again.
    I get through everything and it says the computer will reboot and continue with setup.
    During the reboot, the disk ejects, then I get a black screen that says Disk Error press any key. Nothing happens when you press a key and you have to manually shut down. When I reboot, I get two icons, MAC HD and Windows HD. Yet, nothing comes up when I click on Windows HD.
    PLEASE SOMEONE HELP ME. I have spent hours on this and I really don't think I am THAT stupid.
    I know people don't get paid to help, but if someone could walk me through this. Mac won't help me.

  • New to the world of programing. please help!!

    ello every one.
    I want to start programing and create software on my mac.
    where do i start? i was playing around with terminal and thougth it was cool.
    i went on the net and came across python and discovered it was already in my mac. i dabed with it and it is not easy. all the tutorials iv read seem to be written for someone who has programing experience. Are there any books, websites, anything that will break down programing in python "BARNEY" style.
    or is python the way to go for super beginers. Anyone who can help please do it will be greatly appreciated. Thanks to all.

    Hi,
    Welcome to Apple Discussions! If you want to do programming on your Mac, you'll first want to install the necessary compilers and other tools required. You'll find these on the DVD entitled "XCode" that came with your system. Install XCode first. Then, I'd recommend getting familiar with the software on your machine first, before installing open source software available on the web. You'll probably already have what you want. For example, Perl and MySQL are also included on your machine, in addition to Python, as you have already found out.
    I'd suggest reading the Getting Started page at the Apple Developer Connection, and the Fink website to get an overview of open source software available for OSX.
    As for Python, there's a lot out there on the web. Here is an easy tutorial for non-programmers. Enjoy!
    Ed
    PB G4   Mac OS X (10.2.x)  

  • Got a problem with my Chatting-Room program, please help me if you can.

    There is one bug in the code (should be just one), but I couldn't find it, I even recoded the whole thing, after I recoded the code, the same problem seems still there. I just can't find where the problem is. So I hope someone here can help me, thank you very much.
    First, I made a Server and a Client. Server has 5 classes, and Client has 2 classes. My intention is that all the clients(running on other computers) will connect to the server (which is my laptop), and then they can communicate with each other. For example, if person A typed "Hello", person B and person C's computers will receive this message and display it.
    The problem is that several clients can connect to the server (My laptop), but if one person type something, other people won't receive the message, it's blank on their screens. Maybe there is a problem when server receiving the message. So this is the problem I want to solve.
    I have the code down there, here is a brife description what each class mainly does.
    First class of Server is for connecting client, this class is named Server. Everytime a client is connected, the Server class calls the second class to store the client's information (which is its IP address), the second class is named People.
    Third class is named Receiver, it is for receiving the massage from any one of the clients, then stores the message to a static field variable in Fourth class, fourth class is named Saying.
    Fifth class of Server is named Sender, it is for sending the massage to the client, that message is the one that stored in Saying.
    The First class of client is named Client, it prints any message that the server send to it.
    The Second class of client is named SendFromClient, it wait for user to type something, and then send the message to the server, so server's Receiver class hopefully will get it and store it to the field variable in the Saying class.
    Here is all the codes:
    Server Class:
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Server
         public static void main(String[] args)
              /*port number*/
              final int port = 41333;
              /*welcome messages:*/
              System.out.println("This is FriendlyJ 1.0 running");
              System.out.println("Listening on ports 41333");
              try
                   /*Clear the ArrayList*/
                   People clear = new People();
                   clear.IPs.clear();
                   /*Create a server socket that will accept any connection on this port*/
                   ServerSocket ss = new ServerSocket(port);
                   /*keep getting clients*/
                   while(true)
                        /*connect with one client at a time*/
                        Socket s = ss.accept();
                        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
                        Scanner in = new Scanner(s.getInputStream());
                        /*indicate one establish of connection*/
                        System.out.println("One connection estabolished!");
                        /*two classes, one foe receiving, one for sending*/
                        Receiver receive = new Receiver(in);
                        Thread ty = new Thread(receive);
                        Sender send = new Sender(out, s);
                        Thread yt = new Thread(send);
                        ty.start();
                        yt.start();
                        /*add IP to ArrayList*/
                        clear.storing(s.getInetAddress().toString());
                        out.println("There are " + clear.IPs.size() + " people online;");
                        System.out.println("Connected to " + s.getInetAddress().toString());
              catch (Exception e)
                   System.out.println("System exception");
    }People Class:
    import java.util.*;
    public class People
         ArrayList<String> IPs = new ArrayList<String>();
         /*A method for storing IPs*/
         public void storing(String IP)
              IPs.add(IP);
    }Receiver Class:
    import java.util.*;
    public class Receiver implements Runnable
         final private Scanner in;
         /*Constructor to get the scanner*/
         public Receiver(Scanner abc)
              in = abc;
         public void run()
              Saying say = new Saying();
              try
                   while(true)
                        /*waiting for input from client, then give it to Saying*/
                        say.setSaying(in.nextLine());
              catch (Exception e)
                   e.printStackTrace();
    }Saying Class:
    public class Saying
         static String saying = "";
         public void setSaying(String a)
              saying = a;
         public String getSaying()
              return saying;
         public void resetSaying()
              saying = "";
         public int getlength()
              return saying.length();
    }Sender Class:
    import java.io.*;
    import java.net.*;
    public class Sender implements Runnable
         final private PrintWriter out;
         final private Socket s;
         public Sender(PrintWriter abcd, Socket abcde)
              out = abcd;
              s = abcde;
         public void run()
              out.println("Feel free to chat.");
              int count;
              Saying says = new Saying();
              try
              while(!s.isClosed())
                   count = says.getlength();
                   if(count>0)
                        out.println(says.getSaying());
                        says.resetSaying();
              /*disconnect with the client*/
              s.close();
              System.out.println("Connection with " + s.getInetAddress().toString() + " is closed.");
              catch (IOException e)
                   System.out.println("Network error!");
    }Client Class:
    import java.util.*;
    import java.net.*;
    import java.io.*;
    public class Client
         public static void main(String[] args)
              Socket sc;
              System.out.println("Welcome to FriendlyJ IM program");
              System.out.println("Connecting to the server...");
              int port = 41333;
              /*A variable for storing IP address of Server*/
              InetAddress ip;
              try
                   ip = InetAddress.getByName("192.168.1.68");
                   sc = new Socket(ip, port);
                   System.out.println("Connected with Server");
                   Scanner in = new Scanner(sc.getInputStream());
                   PrintWriter out = new PrintWriter(sc.getOutputStream());
                   /*a thread for sending message to the server*/
                   sendFromClient sendin = new sendFromClient(out);
                   Thread sending = new Thread(sendin);
                   sending.start();
                   /*display welcome message*/
                   System.out.println(in.nextLine());
                   /*displaying how many people are online now*/
                   System.out.println(in.nextLine());
                   while(true)
                        /*print out the message sent by the server*/
                        System.out.println(in.nextLine());
              catch(UnknownHostException e)
                   System.out.println("Couldn't find the host!");
              catch(IOException e)
                   System.out.println("Network error!");
              catch (Exception e)
                   e.printStackTrace();
    }SendFromClient Class:
    import java.io.*;
    import java.util.*;
    public class sendFromClient implements Runnable
         private PrintWriter send;
         public sendFromClient(PrintWriter sendto)
              send = sendto;
         public void run()
              Scanner sc = new Scanner(System.in);
              while(true)
                   /*get a message, then send to the server*/
                   send.println(sc.nextLine());
    That's all, thank you for helping!
    Edited by: stdioJ on Oct 31, 2007 3:58 PM

    Hi pgeuens ,
    I tried it ...but it didn't work for me.
    I changed my .jsp like this
    <%@ page language="java" %>
    <%@ taglib uri="/tags/struts-html" prefix="html"%>
    <html:form action="Registration.do">
    UserName:<html:text property="username"/><br>
    enter password:<htnl:password property="password1"/><br>
    re-enter password:<html:password property="password2"/><br>
    <html:submit value="Register"/>
    </html:form>And i changed that web.xml like..
    <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>Now I am getting an error like ......."File "/WEB-INF/struts-html.tld"not found.
    Hi Ashish
    I didn't find struts-form.tld in WEB-INF folder.But all the remaining file all there.
    Again I downloaded that struts1.2.9 ...in that also i couldn't find struts-form.tld file(except this remaining are there).
    Please tell me, if there any other ways....
    Thanks,
    kona.

  • Keychain problem freezes my programs-Please Help!

    Note: I describe my problem starting when I updated Daylite, but the same thing happened with Safari.
    After upgrading to a new version of Daylite, when I ran the program, I got a dialog box that said, "The 'Daylite' software on your computer has changed and wants access to your computer. Do you want to allow this?" I click allow and then I get a spinning beach ball for Daylite. Force quit takes a while, and even after quitting, my computer slows to a crawl.
    I thought this was a Daylite issue, and posted a question on their boards, but just now, the same thing happened with Safari.
    This must be a Keychain issue. I ran Keychain first aid and repaired permissions. What am I missing?
    Thanks.
    Steve

    Hi ksjinesh
    Provided that you have backed up your phone data you could try resetting your N70 *#7370#
    Happy to have helped forum in a small way with a Support Ratio = 37.0

  • Java Programming Please Help me, Please...

    I have 3 classes, I and I can't import anything, because this is my class project. I won't attempt to lie about it. I've been working on this project for two weeks. My professor usually answers questions, but the University internet is down.
    This is my driver Class.
    import java.io.*;
    import java.util.Scanner;
    public class assignment1 {
         public static void main(String[] args)throws IOException {
              customerList L=new customerList();
              Scanner scan=new Scanner(System.in);
              String input;
              System.out.print("Enter a file name please:");
              input = scan.next();
              L.getCustomerList(input);
              while(true){
                   int a;
                   System.out.print("Enter a Customer Number (between 0-999):");
                   a=scan.nextInt();
                   System.out.println("Customer Record corresponding to "+a+": " +L.getCustomer(input,a));
    This is my customerList.java class.
    import java.util.Scanner;
    import java.io.*;
    public class customerList{
         private customerRecord[] data;
         private int count;
         public customerList(){
              data=new customerRecord[100];
              count=0;
         public void getCustomerList(String fileName)throws IOException{
              Scanner scan=new Scanner(new File(""+fileName+".txt"));
              while(scan.hasNext()){
                   int customerNumber=scan.nextInt();
                   String firstName=scan.next();
                   String lastName=scan.next();
                   float balance=scan.nextFloat();
                   data[count]=new customerRecord(customerNumber,firstName,lastName,balance);
                   ++count;
                   if(count>100){
                        System.out.println("Error, more than 100 records");
         public customerRecord getCustomer(String fileName,int cN){
    This is my customerRecord.java class
    public class customerRecord {
         private int customerNumber;
         private String firstName;
         private String lastName;
         private float balance;
         public customerRecord(int cust,String fName,String lName,float bal){
              customerNumber=cust;
              firstName=fName;
              lastName=lName;
              balance=bal;
         public void setBalance(float bal){
              balance=bal;
         public float getBalance(){
              return balance;
         public void setFirstName(String fName){
              firstName=fName;
         public String getFirstName(){
              return firstName;
         public void setLastName(String lName){
              lastName=lName;
         public String getLastName(){
              return lastName;
         public void setCustomerNumber(int cust){
              customerNumber=cust;
         public int getCustomerNumber(){
              return customerNumber;
         public String toString(){
              return firstName+" "+lastName+" "+balance;
    This is an example of a Record.txt file
    343 Jo Ann 14.37
    199 Rick Jackson 12.22
    Okay, here is what the program is supposed to do:
    First, the user must type in a file name, the file name in my example is Record.txt but it must work for any file typed in. That part works for me. The user types in a customer Number, in my text file that would be 343 or 199 as and example. Then, the corresponding first name, last name, and balance appears in the console. The array must be 100 in size.
    Now here is my question, In my customerList.java I must have a getCustomer(int cN) method. This searches the array to find the corresponding customer record. How am I supposed to do this? I've tried everything.
    I know it must use a for loop, and a if statement inside that. But, I don't know how I can compare the data, to a record. Any suggestions would be much appreciated.

    Now here is my question, In my customerList.java I
    must have a getCustomer(int cN) method. This
    searches the array to find the corresponding customer
    record. How am I supposed to do this? I've tried
    everything. Everything? Like what?
    Why can't you iterate through the list of customer records and compare the customerId for each one to the value you passed as a parameter? when you get a match, return the customer record that matched. if you don't find one, return null. pretty simple. what's wrong with that?
    I know it must use a for loop, and a if statement
    inside that. But, I don't know how I can compare the
    data, to a record. Any suggestions would be much
    appreciated.
    What's data?
    Maybe something like this:
    public CustomerRecord find(int customerId)
        CustomerRecord thisCustomer = null;
        for (int i = 0; i < customerList.length; ++i)
            if (customerList.getCustomerId == customerId)
    thisCustomer = customerList[i];
    break;
    return thisCustomer;
    I used the naming conventions that I'd be using. Adapt the ideas to your stuff.

Maybe you are looking for

  • How to customise "Sounds" in Mail??

    Hello everyone... I have used Mac OS X for quite a long time but have never get around to using Mail until recently at the office... (Been using Entourage...) How do you customise "sounds" in Mail? i.e. Not only for 'New Incoming Mail' (which I saw,

  • Help with Graph

    Hi All In a report i have field called "CERTIFY" and it has two values 1 and 2. Based on this i create a calculation: CASE WHEN DW_MDSS_ROUTE_SO_POST.CERTIFY = '1' THEN COUNT(DW_MDSS_ROUTE_SO_POST.CERTIFY) WHEN DW_MDSS_ROUTE_SO_POST.CERTIFY = '2' THE

  • Pdf documents not viewable

    Before i updated the adobe reader, all my pdf documents were viewable on the documents section of the adobe reader. Since i updated the app under the documents section there are no pdf's shown like before. These pdf's are saved on my android tablet d

  • Combine report list for SAP-PP module

    Respected SAP GURU,s Can any body give me the combined report list of SAP-PP modules or give some direction to search it. SFC route is not required... pl reply urgently Rewards point will be given. VEDANT

  • Jambox had no problem to connect with iPhone 4 S but my new iphone 6 can not see the jambox. Any solution known?

    I used my jambox with the iPhone4S via bluetooth without problems. Now i changed to the new iPhone 6 and the new phone can not see the jambox. Is that known and what solution is available?