Help writing programs!

I have recently taken it upon myself to learn Java, and I am having a few problems with a few programs. I am not understanding how to do certain things when writing the program. I am taking this class as an independent study, but we have a general guideline of programs that may help us prepare for the A.P. Exam. On of the programs that I am having difficulty with is a program designed to remove blanks. I have looked on the internet and found programs, but I need to write it in a certain way using arrays.
I am using BlueJ.
What I have so far is:
import java.util.ArrayList;
public class RemoveBlanks
String withblanks;
String removeblanks;
int num = 0;
ArrayList Array;
ArrayList Letter;
Letter = new ArrayList();
Array = new ArrayList();
EasyReader kboard = new EasyReader();
withblanks = "Take out these spaces";
//System.out.println("Input a sentence to remove the blanks in.");
//withblanks = kboard.readLine();
Array.add(withblanks);
for (num = 0; num < Array.size(); num++)
Letter[num] = Array.charAt(num);
if (Letter[num] == " ")
Array.add(removeblanks);
I honestly have no idea if this even makes sense. The book I am using is expecting that you already are familiar with the syntax and the language in general. I would appreciate it if someone could help guide me on how to do this the right way. Thanks in advance!

In the future, post code between [co[i]de] tags. Some pointers:
1) You're confusing arrays and ArrayLists, they are two very different things.
2) All variable names should begin with lower case letters.
3) It is pointless to have two { in a row.
4) In order for a program to run, it needs a main() method.
5) Always compare Strings with the equals() method, not ==.

Similar Messages

  • Need Help writing program

    very new to java, i conceptually know what i want to do, but it is hard to apply that to writing the program. this is very introductory so i'd appreciate all and any help.
    i am trying to write a program such that if I select an integer, n, as in input, the program can convert that integer into it's binary representation. for example, if the integer is 4, then the program would output 001 as the binary representation of 4.
    that is the first part, the second part is to have the binary representation go from most significan bit to least significant bit, so for the integer 4 it will come out as 100 (or 000100 or 00100).
    ok basically i know i want the program to divide the chosen integer by 2 and take the remainder (n%2), which will be 1 or 0. i then want the program to take the value (n/2) and have that be the new n value, then repeat the steps over and over till my n just becomes 0. i am trying to do this with a while loop, but if there is an easier way to do this, please let me know. so far wha ti have is below, kinda stuck on how to write this program, please help. the output just keeps giving me 0 and doesn't end.
    import java.util.*;
    class Q3a{
    static Scanner console = new Scanner (System.in);
         public static void main(String args[]){
              int n;
              n = console.nextInt();
              System.out.print("Choose an integer value :");
              while (true) {
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;}
              System.out.println("New value of n is n/2 which is " + n);
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;
              System.out.println("New value of n is n/2 which is " + n);
              System.out.println("Remainder on dividing " + n + " by 2 is " + n%2);
              n = n/2;
              System.out.println("New value of n is n/2 which is " + n);Message was edited by:
    kribraider414

    consider
    while (n != 0){
      System.out.println(n%2);
      n = n/2;
    }put the reverse of the stoping condition in the parens for the loop
    This loop will run while n is NOT zero. It wil stop when n is zero. Try it for a few numbers and see what it does.
    Pay particular attention to what it does if the number you supplied is zero (which is the one binary number that does not have a single one in it.)
    Also take a look at what it does for negative numbers and decide what you want to do in that case.

  • Need help writing host program using LabView.

    Need help writing host program using LabView.
    Hello,
    I'm designing a HID device, and I want to write a host program using National Instrument's LabView. NI doesn't have any software support for USB, so I'm trying to write a few C dll files and link them to Call Library Functions. NI has some documentation on how to do this, but it's not exactly easy reading.
    I've written a few C console programs (running Win 2K) using the PC host software example for a HID device from John Hyde's book "USB by design", and they run ok. From Hyde's example program, I've written a few functions that use a few API functions each. This makes the main program more streamlined. The functions are; GetHIDPath, OpenHID, GetHIDInfo, Writ
    eHID, ReadHIC, and CloseHID. As I mentioned, my main program runs well with these functions.
    My strategy is to make dll files from these functions and load them into LabView Call Library Functions. However, I'm having a number of subtle problems in trying to do this. The big problem I'm having now are build errors when I try to build to a dll.
    I'm writing this post for a few reasons. First, I'm wondering if there are any LabView programmers who have already written USB HID host programs, and if they could give me some advice. Or, I would be grateful if a LabView or Visual C programmer could help me work out the programming problems that I'm having with my current program. If I get this LabView program working I would be happy to share it. I'm also wondering if there might already be any USB IHD LabView that I could download.
    Any help would be appreciated.
    Regards, George
    George Dorian
    Sutter Instruments
    51 Digital DR.
    Novato, CA 94949
    USA
    [email protected]
    m
    (415) 883-0128
    FAX (415) 883-0572

    George may not answer you.  He hasn't been online here for almost eight years.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Need help writing small program!

    Hi. I'm learning Java programming, and I need help writing a small program. Please someone help me.
    Directions:
    Create a program called CerealCompare using an if-then-else structure that obtains the price and number of ounces in a box for two boxes of cereal. The program should then output which box costs less per ounce.

    class CerealCompare {
        public static void main(String[] args) {
            // your code goes here
    }Hope that helps.
    P.S. Java does not have an if-then-else statement.

  • Help writing a excel macro to do a copy of 4 cells and paste transpose. I need to loop the copy and paste through 6900 rows of data.

      I need help writing a excelmacro to do a copy of 4 cells and paste transpose.  I need to loop the copy and paste through 6900 rows of data.  I started the macro with two rounds of copying & paster transposed but I need help getting it
    to loop through all rows.  Here is what macro looks like now.
        Range("I2:I5").Select
        Application.CutCopyMode = False
        Selection.Copy
        Range("J2").Select
        Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
        Range("I6:I9").Select
        Application.CutCopyMode = False
        Selection.Copy
        Range("J6").Select
        Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=True
    End Sub

    Thanks Jim for the solution above.
    Hi Brogents,
    Thanks for posting in our forum. Please note that this forum focuses on questions and feedback for Microsoft Office client. For any
    VBA/Macro related issues, I would suggest you to post in the forum of
    Excel for Developers, where you can get more experienced responses:
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=exceldev
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Need Help Writing Server side to submit form via API

    Hey
    I need help writing a serverside application to submit
    information via API to a separate server.
    I have a client that uses constant contact for email
    campaigns. We want to add to her website a form taht submits the
    information needed to subscribe to her email list, to constant
    contact via API.
    FORM.asp :: (i got this one under control)
    name
    email
    and submits to serverside.asp
    SERVERSIDE.ASP
    In serverside.asp i need to have
    the API URL
    (https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp)
    username (of the constant contact account)
    password (of the constant contact account)
    name (submited from form.asp)
    email (submitted from form.asp)
    redirect URL (confirm.asp)
    Can anyone help get me going in the right direction?
    i have tried several things i found on the net and just cant
    get anyone to work correctly.
    One main issue i keep having is that if i get it to submit to
    the API url correctly - i get a success code, it doesnt redirect to
    the page i am trying to redirect to.
    ASP or ASP.NET code would be find.
    THANKS
    sam

    > This does require server side programming.
    > if you dont know what that is, then you dont know the
    answer to my question. I
    > know what i need to do - i just dont know HOW to do it.
    If you are submitting a form to a script on a remote server,
    and letting
    that script load content to the browser, YOU have no control
    over what it
    loads UNLESS there is some command you can send it that it
    will understand.
    No amount of ASP on your server is going to change what the
    remote script
    does.
    http://www.constantcontact.com/services/api/index.jsp
    they only allow their customers to see the instructions for
    the API so i
    can't search to see IF there is a redirect you can send with
    the form info.
    But posts on their support board say that there is.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • When downloading pdf files the acrobat reader is not in the group of "Choose Helper Application" programs.

    No matter what I try I can never get the Acrobat Reader to be added to the group of "Choose Helper Application" programs available in that window when downloading a pdf. I always have to browse to the Acrobat reader and select it that way.
    I have enabled Acrobat in the add-ons manager, but that has not solved the problem.
    In the options > applications menu I've selected use Acrobat Reader for pdf files but that doesn't work and furthermore doesn't seem to stick. That is, sometimes when I check that menu later the selection has reverted to "always ask".
    I'm using Firefox 32 on Windows 7. I have used Firefox on XP for years and never had this problem.

    Here are some screen shots to backup my claims.

  • Search help with programming

    Hai,
    Can any one give example for search help with Programming?
    I hope we can create search help with help of coding.
    With Regards,Jaheer.

    yes u can create search help by using match code in programs
    for eq
    go with abap editor se 38
    provide the name of program
    parameters : vendor like lfa1-lifnr matchcode object yzob.
    double click on yzob
    provide description for search help
    provide selection method
    provide search help parameter
    enable check box for import and export
    provide lpos
               spos
    save check activate
    press f4 for check and import values i.e it will display a records list available in database table
    rewards points please

  • Writing Programs for Intel Mac?

    I am a writer of young adult fiction novels.
    I want to get a writing program for my new Intel based iMac.
    Should I spend $150 for Microsoft Word and get a bunch of other apps I don't use and won't need?
    Or, is there one, online, that is free or inexpensive that will allow me to write my stories and create readable files for other computers as well as PDFs?
    Best,
    Evan Jacobs
    www.anhedeniafilms.com

    Have you visited < www.puremac.com > ????
    They have classified links to finding everything you will need in the way of Macintosh software.
    There are SO VERY many companies that make wonderful desktop publishing programs you have never heard of.
    Or, better still, go to <www.mause.ca > and download some of the 2007 DoubleClick newsletters: look for reviews of DesktopPublisher Pro, Ready,Set,Go!, QuarkXPress 7, Swift Publisher, MLayout, RagTime & RagTime Solo, Mariner Write, and others. For a while they had a few reviews of excellent desktop publishing articles in every issue.
    Check them out !!!!!

  • I switched to Apple Mail in the last two months.  When I attempt to print an email message, I get a blank piece of paper.  When I attempt to use the print options suggested in "Mail Help", the program crashes and has to be reopened.  Any ideas?

    I switched to Apple Mail in the last two months.  When I attempt to print an email message, I get a blank piece of paper.  When I attempt to use the print options suggested in "Mail Help", the program crashes and has to be reopened.  Any ideas?

    Which version of Mail are you using as well as which Snow Leopard version you are using? 

  • Adding the search help in program

    hi i want to add a search help in program for a particular field of a parameter how to do this?

    U need to create a serach help exit for this purpose.
    F4IF_SHLP_EXIT_EXAMPLE - documents the different reasons to use a search help exit, and shows how it is done.
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_exit.htm
    http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_basic.htm
    Create an Elementary Search help:
    Eg: Zsearch
    In the defintion tab:
    Give the search help exit name: Zsearch_exit.
    Also give the search help param and data element.
    Copy F4IF_SHLP_EXIT_EXAMPLE into Zsearch_exit
    Comment:
    callcontrol-step = 'SELECT'.  (1st line)
    Inside:
      IF CALLCONTROL-STEP = 'SELECT'.
    Select required data for the search help
    Select stmnts as per your requirement and populate in itab.
    Move all the selected records to Record_Tab
        LOOP AT itab INTO wa_itab.
          MOVE wa_itab TO record_tab-string.
          APPEND record_tab.
          CLEAR record_tab.
        ENDLOOP.
        RC = 0 .
        IF RC = 0.
          CALLCONTROL-STEP = 'DISP'.
        ELSE.
          CALLCONTROL-STEP = 'EXIT'.
        ENDIF.
        EXIT. "Don't process STEP DISP additionally in this call.
    Let me know if its working for you.
    Also, chek this link if it helps you:Re: Find Storage location with respect to Plant

  • Need help writing a query for following scenario

    Hi all, I need some help writing a query for the following case:
    One Table : My_Table
    Row Count: App 5000
    Columns of Interest: AA and BB
    Scenario: AA contains some names of which BB contains the corresponding ID. Some
    names are appearing more than once with different IDs. For example,
    AA BB
    Dummy 10
    Me 20
    Me 30
    Me 40
    You 70
    Me 50
    Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
    I would appreciate any input. Thanks

    Is it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
    With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
    WITH t AS (
    SELECT 'me' aa, 10 bb FROM dual
    UNION ALL
    SELECT 'me' aa, 20 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    UNION ALL
    SELECT 'you' aa, 30 bb FROM dual
    SELECT DISTINCT aa, bb
      FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
    WHERE cnt > 1;

  • Help writing a workflow rule

    Hello Experts!!!
    I need help writing a workflow rule condition to trigger the workflow. What I am aiming for is an email to be sent out when an opportunity is marked Closed/Won. But it can only be of a certain opportunity type (we use three options) and opportunity sub-type (we use two options) (these are custom fields we use)
    Below are the fields that need to be used:
    [<SalesStage>] = Closed/Won
    [<OpportunityType>] = Acute
    [<plOpportunity_SubType_ITAG>] = Tech
    Thanks Again!!

    Hi
    Try:
    [<SalesStage>] = Closed/Won AND [<OpportunityType>] = Acute AND [<plOpportunity_SubType_ITAG>] ='Tech'
    Note that in case of picklists it is recomended to use the lookup value and not static text like 'Tech', but both will work.
    Good luck
    Guy

  • I want parameters with f4 help for program names in value request

    I want parameters with f4 help for program names in value request
    points will be awarded if  useful

    lv_name1 TYPE name1,        "Vendor Name
    CALL FUNCTION 'POPUP_TO_SEARCH_VALUE'
        EXPORTING
          textline1   = 'Vendor Name'(f09)
          titel       = 'Enter'(f17)
          valuelength = 35
        IMPORTING
          value       = lv_name1.
    try this out ..

  • Search help freely programmed

    Hi all,
    is anyone able to explain me how to use Search Help freely programmed?
    thanks
    GN

    Hi Gabriele,
    Please go through the component DEMO_VALUE_HELP. This explains all the input help types. The freely programmed search help has been implemented for the CONNID input field of view V1. The Web Dynpro component FREE_VALUE_HELP in the same package is the component where the search help is coded.
    Also below are the steps to be followed for implementing the freely programmed search help.
    This kind of value help is implemented as a Web Dynpro component implementing the Web Dynpro
    component interface IWD_VALUE_HELP. To be able to use the value help for a certain input field, the following steps are necessary:
    1) A component usage of the value help component (HC) has to be declared
    by the consumer component (CC).
    2) A usage of the HC interface controller has to be declared in the CC view.
    3) The input help mode User-Defined Programming has to be chosen for the attribute that is bound to the input field under consideration. The HC usage must be related to this attribute. The component interface of the HC has only one method: set_value_help_listener( ). This method is called by the Web Dynpro runtime if the value help button of the input field under consideration is clicked. The HC has to be implemented as follows:
    1) The method set_value_help_listener( ) has an import parameter. This means that the reference to the listener, provided by the Web Dynpro runtime, is passed to the user-defined HC. This reference has to be saved as a user defined controller attribute.
    2)  To close the help value dialog box, the close_window( ) method of the listener has to be used.
    3)  All views have to be embedded into a window having the name WD_VALUE_HELP. This name is used by the Web Dynpro runtime.
    4) To exchange data between the CC and the HC, context mapping can be used.
    For implementing the component interface IWD_VALUE_HELP, you need to choose the Reimplement button in the HC. The implementation status changes to green and the events and the method of the component interface are visible in the HC controller.
    Regards,
    Uday

Maybe you are looking for