Help pelase not printing as i want it

Hi This program stores names of towns in an array. Then the user does a search and it has to print out where that town is in the array. Here is my code.
import java.util.Scanner;
public class ArrayTwo
     public static void main(String args[])
     Scanner keyboard = new Scanner(System.in);
     String[] B = {"Halifax", "Enfield", "Elmsdale", "Truro", "Springfield", "Sackville", "Moncton"};
      System.out.println("Please enter the name of a town ");
      String townName = keyboard.next();
      for (int index = 0; index < B.length; index++)
           if(townName.equals(B[index]))
                System.out.println(townName + " is in position " + B[index]);
I dont know how to print it out because the way i have it printing it says.
The position of Halifax is Halifax.
How do i make it print out like
The position of halifax if 1

B[index]This says get me the element in the array B at position index. So it will print out the name. What do you think you should use if you want to print out the position in the array instead?

Similar Messages

  • Printer Friendly Pages is NOT printing what I want

    So I tried to use the 'addthis' and added it to the main content div. However, lists, bullets, etc. are not printing as expected. I am seeing "code" for example if I try to print on the main page (though on the main page there is not a lot of 'content').
    I could add it to the individual content page layouts, but it is still not printing summary links, or other lists the way that I want. 
    I just want to print the content on the page. I am thinking jquery or writing a CSS for print. I really want to use the addthis and this is making me think I did something wrong. Any ideas on the best approach for printing "printer friendly pages"
    on SharePoint 2010?

    So I tried to use the 'addthis' and added it to the main content div. However, lists, bullets, etc. are not printing as expected. I am seeing "code" for example if I try to print on the main page (though on the main page there is not a lot of 'content').
    I could add it to the individual content page layouts, but it is still not printing summary links, or other lists the way that I want. 
    I just want to print the content on the page. I am thinking jquery or writing a CSS for print. I really want to use the addthis and this is making me think I did something wrong. Any ideas on the best approach for printing "printer friendly pages"
    on SharePoint 2010?

  • Need help returning (not printing) avg GPA from array??

    Here's what I have so far. After returning the value then I gotta print the avg in a separate method. I also need to check the names of the first and last student using an "equals" method. Please someone help with whatever you can. Here's what I got:
    import java.util.Scanner;
    public class StudentLists {
    //Main method. Prompts user for the number of students.
       public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       System.out.print("Please enter the number of students in this class: ");
       int s = in.nextInt();
       Student[] students=new Student[s];
       FillStudents(s,students);
       printAll(students);
       public static void FillStudents(int s, Student[] students){
       for (int i=0; i<s; i++)
            Scanner inf = new Scanner(System.in);
            System.out.println("Please enter student's first name: ");
        String first = inf.nextLine();
        System.out.println("Please enter student's last name: ");
            String last=inf.nextLine();
            System.out.println("Please enter the number of credits completed: ");
            int c=inf.nextInt();
            System.out.println("Please enter student's GPA: ");
            Double g=inf.nextDouble();
            students[i] = new Student(first, last, c, g);
        public static void printAll(Student[] students) {
        System.out.println("Names      Credits  GPA");
           for(int i = 0; i < students.length; i++)
        System.out.println(students);
    public static Double getAvg(Student[] students, Double g){
    double sum=0.0;
    double avg=0.0;
    for(int i=0; i<students.length; i++){
    sum+=g;
    avg=sum/students.length;
    return avg;

    Oh no I wasn't giving any orders. I was saying I have been trying to edit what I have, but I can't figure out how to get the method right to do my average of the GPA from the loop. I don't know what to put in there. I was just asking if you would write it and then kind of explain what u did for me please.
    import java.util.Scanner;
    public class StudentLists {
    //Main method. Prompts user for the number of students.
       public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       System.out.print("Please enter the number of students in this class: ");
       int s = in.nextInt();
       Student[] students=new Student[s];
       FillStudents(s,students);
       printAll(students);
       public static void FillStudents(int s, Student[] students){
       for (int i=0; i<s; i++)
            Scanner inf = new Scanner(System.in);
            System.out.println("Please enter student's first name: ");
        String first = inf.nextLine();
        System.out.println("Please enter student's last name: ");
            String last=inf.nextLine();
            System.out.println("Please enter the number of credits completed: ");
            int c=inf.nextInt();
            System.out.println("Please enter student's GPA: ");
            Double g=inf.nextDouble();
            students[i] = new Student(first, last, c, g);
        public static void printAll(Student[] students) {
        System.out.println("Names      Credits  GPA");
           for(int i = 0; i < students.length; i++)
        System.out.println(students);
    public static Double getAvg(Student[] students){
    double sum=0.0;
    double avg=0.0;
    for(int i=0; i<students.length; i++){
    avg=sum/students.length;
    System.out.println(avg);
    return avg;

  • Photosmart c6180 does not print the page what i want

    i have photosmart hp c6180 and it is connected to my wireless laptop the problem is when i try to print some it does not print the same page but it prints some weired pages and keep printing but still does not print what i want. please help me on this issue i would really appreciate. thanks

    Have you tried deleting the printer and reinstalling?  At least you are getting the printer to do something.  My print job just gets hung up in queue.

  • HP Photosmart 6510 black ink does not print;

    The Photosmart 6510 prints in color ink but not in black.  I cleaned the printhead, checked the ink cartridges, and even installed a new HP black ink cartridge .  Still it does not print.  HP wants me to spend $59 to get tech support to help me resolve this problem.  That is not something I am going to do.  If anyone has a suggestion, I would appreciate it.
    Thank you.

    Hi @sblilly 
    Have you completed all of the steps in the following document; Printer Does Not Print Black Ink or Color Ink, or Prints Blank Pages.
    Although I hope this resolves the issue, it might not. If the issue persists, please post back with your warranty status. Use the following link to check your warranty.
    If your printer is still in warranty, please call HP and explain the issue you are experiencing. The number to call HP is 1-800-474-6836 for Canada and US, or you can Contact HP Worldwide.
    If your printer is out of warranty, let me know and I will do my best to help. Thanks. I look forward to hearing from you.
    I need to know your Country/region, Please include your country/region in your next post. Thanks.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • My photosmart D110 printer will not print at all wireless or when connected; the printer will copy .

    My D110 Photosmart printer will not print when I want to have something printed from my laptop; I have made sure everything was connected. I have lost the the disk that came with it. Please help the serial# {Removed for privacy}
                                                                       Thank You, Kevin Jackson

    What operating system?  Running the diagnostics at http://www.hp.com/go/tools may help resolve the issue.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    I am having trouble printing I have a connection to my printer wirelessly but does not print out the correct page I want.When I do print I get a bunch of pages more than is needed and also get a code and symbols please help I am jammed at work

    This can be the result of selecting the wrong driver. An older, unsupported laser printer will sometimes work with the generic Postscript driver.

  • I just updated my Ipad 2 last night with iOS 7.04 now I can't print shipping labels from Paypal. I downloaded a different browser, Dolphin, per Paypal's suggestion. Still can not print. It says it has lost connection with the server.help!.

    Hello! I updated my Ipad now I can not print USPS labels from Paypal. I used my boss' Ipad not updated and worked fine. I am dependent on my Ipad to print these labels for me. I can print anything else I want, like email or packing slips. Any thoughts? I would go back to the previous version if anyone knows how to do that.

    Hello Sapo11,
    To get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial product. You can do this at Commercial Forums.
    Thanks for your time.
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • I have a business and I use iCal for all my appointments, how can I print receipts from my MacBook to a receipt printer? I want my clients to have a receipt of the services that they have paid for, can anyone HELP ME PLEASE?

    I have a business and I use iCal for all my appointments, how can I print receipts from my MacBook to a receipt printer?
    I want my clients to have a receipt of the services that they have paid for, can anyone HELP ME PLEASE?

    Well...I went to the modem (Westell, WireSpeed), found the NAT settings, once again, I'm WAY over my head, I am assuming this is a TCP connection (as opposed to a UDP) and per Lorex my mobile devices will use port 1025.  So I gave it a "global port range" of 1-10 and I indicated that the "base host port" was 80, 1025, & 9000 (ports 1,2,3).  When I selected the 'enable' it asked for a "host devise" my choices are my IPhone, IMac and the IP address for the dvr, so I choose the dvr.  I still cannot connect and canyouseeme still can NOT find these open ports.  This is taking up my whole day! I don't know how people figure this stuff out.

  • Help - photos are not printing from photo tray uToshiba Laptop

    Hello,
    I just got a new toshiba satellite laptop and when I try to print photos using the glossy photo paper in the photo tray, it keeps pulling from the regular paper tray. I have tried selecting all kinds of the HP paper, but it still prints out on regular paper.  I also have a desktop and I have the exact same settings as that and the desktop pulls from the photo tray but the laptop doesn't. Can anyone help?
    Thanks so much,
    Shelly

    If you are unable to print photos, the first thing that comes to mind is that you have the wrong tray selected.  I would start with Solution 4 of this document for a walk-through on how to setup the photo tray.   I know you are not experiencing an out of paper error message but it covers all of the steps you would take to print to the photo tray.  This printer has ePrint.  Have you set that up yet?  I am curious because I want you to try to email the printer an attachment of your photo because ePrint photos default to 4x6 and go straight to the paper tray.  This test will narrow down to if this is a printer problem or a setting in your computer.  Read through that link and let me know if it helps or not.  If not, how is the printer connected to the computer and what kind of computer are you using?
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • IAhave am iPad 1. I downloaded PrintCentral Pro and also the Bonjour Printer Wizard as prompted. I still can not print. What am I missing?  I am new to this...Please help.  Thank you!

    I have an iPad 1. I downloaded PrintCentral Pro and also the Bonjour Printer Wizard as prompted. I still can not print. What am I missing?  I am new to this...Please help.  Thank you!

    Depending on what you are trying to print you may have to print from within the app.  For example, to print an email or web page you have to open what you want to print from print central pro.  If your printer is not a supported printer there is another app from the same developer that allows you to print from your iPad to your printer via a wired pc.  You may want to drop them an email.  They have pretty good customer service and respond to emails very quickly.

  • Help! Not able to Print TIF files

    I recently pasted 4 photos into a 19x13 canvass. The file was originally a 1.2 GB file, which would not print, so I then reduced the size to approximately 700MB. I go to FILE then select PRINT and nothing happens. Is there a setting I messed up somewhere?
    I am using CS5 Version 12.0.1 64 bit. I have no issue printing any other TIF photos.
    One thing I noticed is that I can not save this particular TIF, (thinking that maybe a JPEG would work),  in any other format except Photoshop/Large Document Format/open EXR/Portable Bit Map/Radiance/TIF, no other options. It was be something terribly simple that I am just baffled with. I am really puzzled and frustrated as I really want to print this new file ASAP.
    Any suggestions and/or help would be greatly appreciated.

    The Adobe Color Engine can't take a 32 bit file as input and spit out a 16 or 8 bit file?  That's a surprise.
    -Noel

  • HT3412 Want to order books but received the following message, "your book appears to have unedited text which will not print in your book."  What does that mean?

    Please help.  Want to order completed book but received the following message, "your book appears to have unedited text which will not be printed in your book."  What does that mean?  Why did the program let me use text that will not print?

    Go thru every page in the book and look for any text box.  Unused text boxes will have somegthing like this in them:
    or this:
    Just put a space in those text boxes where you didn't put text previously.  Check the inside flaps of the book jacket also.

  • Why does the software update say that drivers for my printers are not available? I have the drivers installed from the CD but can't add the printer because it wants to go through software update.

    I have the latest operating system, but can't get my printers added. Why does the software update say that drivers for my printers are not available? I have the drivers installed from the CD but can't add the printer because it wants to go through software update.

    It's pretty difficult to offer suggestions when you say nothing about your Mac, the version of Mac OS it's running, or the models of printers you have. This forum, however, is intended for questions about old, pre-G3 hardware, so unless you are asking about an very old Mac, this is not the forum where you'll be most likely to get help with your problem. I'd suggest you ask this question in the forum for your model of Mac or version of Mac OS X it's running. You'll be more likely to get assistance there, assuming you provide sufficient detail for anyone to make a diagnosis of the problem.
    Regards.

  • Hi there can anyone help as i am unable to contact Apple for support with my printer which will not print after recent software update? this is the email i tried to send to apple with no success, can anyone help please.......Dear Apple, I'm pulling my hai

    Hi there,
    Can anyone out there help, after a recent Apple software update my Epson Stylus Photo RX640 will no longer print, every other aspect of the printer works fine including the scanner but it just will not print, I sent an email to apple but all i got was an automated reply directing me to their support page, the email i sent is below this explains in full what the problem is & what i have done to try & fix this problem.
    Dear Apple,
    I'm pulling my hair out after a recent software update from apple, since this update my Epson Stylus Photo RX640 will not print, every other function of the printer including the scanner works fine,
    Please see attached file of the error message coming up in the print queue.
    I have spent days trying to fix this, i have been onto Epsons website & followed their resolution for this error message to no avail, after contacting them again with the results i got an email back saying : In response to your email, the RX640 will use an inbox or gutenprint driver on Mac OS X 10.6.8, it is not compatible with an Epson driver.
    I have also tried re-installing drivers from original Discs for the printer but it still will not print, obviously this error has been caused by Apple's latest software update, when are Apple going to fix this problem? i need my printer working ASAP.
    Regards
    Brian
    PS i obviously can't attach the error message so here it is:    Error:/Library/Printer/Epson/inkjetprinter 2/filter/rastertoescpll.app/contents/mac os/rastertoescpll/failed
    Thank You all in advance
    Regards
    Brian

    It is hardly Apple's fault that Epson can't/won't update their driver, but at least Epson suggest that you use the Gutenprint driver, which in any case is far better that what Epson offer.
    You can get it here:
    http://gimp-print.sourceforge.net/
    You can download the latest version from here:
    http://sourceforge.net/projects/gimp-print/
    Have you downloaded the recent Apple update to Epson drivers?
    http://support.apple.com/kb/DL1398

Maybe you are looking for

  • LWAP issues with a 5508 controller after AP upgrade

    Hi All, I’m having a few problems after upgrading my AP to a LWAP and hope you can help. I have an AIR-AP1242AG-E-K9 which had c1240-k9w8-mx.124-21a.JA loaded, I followed the link below and upgraded with Cisco’s upgrade tool to c1240-rcvk9w8-mx with

  • The schedule in Power BI report refresh error with the powerpivot or powerview with SQL Analysis services as data source

    In the Power BI Admin Centre, the data sources that cannot be setup with Analysis services, and it has the error to schedule the powerpivot or powerview report to have data refresh. The error is "我們無法重新整理此報表中的資料來源種類." - english, "We can not rearrange

  • Can't reopen a activex player I a popup.

    Hi I have a popup that plays a video file. First time I open it works, but not the second time. I keep the refrerence in a shift register. If I never close the popup I don't get the problem. I think labview is messing with the reference when the wind

  • DAO pattern datasource connection help

    After researching and attempting to implement the Data Access Object pattern using the Abstract Factory pattern I run into one problem for which I haven't found a solution. All of the solutions that I have found hardcode the database connection URL a

  • Google Toolbar crashing Firefox 3.6.8

    Firefox 3.6.8 crashes when accessing Add-on Manager and Google Toolbar (v 7.1.20100723W) is enabled Running Firefox 3.6.8 on a Win7 64x HP dv7 notebook Receive the following "Warning: Unresponsive Script" box when accessing Add-ons Manager... Content