Cannot Get This Program To Compile

Can someone please review this question and help me to fix the syntax. I will also post the question so that you have an idea of what is going on. I am very frustrated about this problem. I just can't get it to work and I really don't know all of the commands. I am a novice to Java.
The letters of a word are stored in an array str with the first letter in str(1), the second in str(2), and so on. The character ?$? is placed in the array after the last letter of the word to indicate the end of the word.
Suppose that str contains m letters (excluding ?$?).
Write a program to:
1. Allow the user to read a word into the array str. Assume that there is no word longer than 100 characters.
2. Read an integer value (n > 0) and a letter, ?letter?. Your program must insert letter after the nth letter in str. The letters to the right of the nth letter (including ?$?) must be shifted right by one position to make room for letter. Validate the value of n.
3. To delete a letter, 'error', from the word all the letters following 'error' must be shifted left by one position to overwrite 'error'. Your program must prompt the user for the letter 'error' and delete the letter from the word.
import java.io.*;
public class Assign5
public static void main(String[]args) throws IOException
char str[] = new char[100];
int count =0;
BufferedReader read = new BufferedReader (new InputStreamReader (System.in));
String word;
String letter;
String input;
System.out.println("******Word Count, Formation & Reformation Function******");
System.out.println("\nEnter your word of choice ending with $ e.g. Scavenger$ ");
word = read.readLine();
do
if (Character.isSpaceChar(word.charAt(count)) == true)
System.out.println("You forgot the $ to indicate the end of the word");
System.out.println( "Enter word to which manipulation must be done, ending with $ e.g. Scavenger$");
word = read.readLine();
str[count]= word.charAt(count);
count ++;
}while (str[count -1] != '$');
int m = count -1;
System.out.println("\nThe number of letters in the word is " +m);
//Word Re-Formation Function
System.out.println("\nEnter a letter that you wish to stuff into your word");
letter = read.readLine();
System.out.println( "\nEnter the letter position (an integer) after which to stuff your letter");
input = read.readLine();
int n = Integer.parseInt(input);
n = n - 1 ;
while(n <= 0)
System.out.println("\nI am sorry...that position is invalid");
System.out.println("\nEnter the letter position (an integer) after which to stuff your letter");
input = read.readLine();
n = Integer.parseInt(input);
n = n-1;
char temp[] = new char[100];
int index = 0;
for(int i = (n+1);i <= m; i++)
index = index +1;
temp[index] = str;
str[n +1] = letter.charAt(0);
index = 1;
for(int i = (n+2); i <= (m+1) ; i++)
str = temp[index];
index = index + 1;
//Printing the new word
System.out.print("\nThe new reconstructed word is: ");
for(int i = 0; i <= m ; i++)
System.out.print(str);
System.out.println();
int newM = m + 1;
//Error Correction Module
System.out.print("\nThe new reconstructed word is: ");
for(int i = 0; i <= m ; i++)
System.out.print(str);
char errorLetter[] = new char[1];
do
System.out.println("Enter a letter that you wish to remove from your word");
input = read.readLine();
errorLetter[1] = input.charAt(1);
int position = 0;
for(int findLetter = 1; findLetter <= newM; findLetter++)
if(errorLetter[1] == str[findLetter])
position = findLetter;
if(position == 0)
System.out.println("I am sorry?that letter is NOT contained in the word.");
errorLetter[1] = ' ';
position = 0;
}while (errorLetter[1] == ' ');
System.out.println("The new word formed after removing your letter is: ");
for(i = 1; i = 100; i++)
if(i = position)
str = temp[i + 1];
for(fillLoop = i + 1; fillLoop = 99; fillLoop++)
str[fillLoop] = temp[fillLoop + 1];
for(i = 0; i = 100; i++)
System.out.print(str[fillLoop]);
}

As I'm sure the compiler would help you find out, there are a few problems in this:
1. You treat str as if it's a single char, when in fact it's a char array (char[]). If you want to copy an element in str to temp, you have to do it like str[i] = temp
2. You are not properly declaring your variables in your loops. You have to declare every variable before you use it, so this is wrong:
          for (i = 1; i = 100; i++) {
               if (i = position) {
                    str = temp[i + 1];
                    for (fillLoop = i + 1; fillLoop = 99; fillLoop++) {
                         str[fillLoop] = temp[fillLoop + 1];
          }It should instead be
          for (int i = 1; i = 100; i++) {
               if (i = position) {
                    str = temp[i + 1];
                    for (int fillLoop = i + 1; fillLoop = 99; fillLoop++) {
                         str[fillLoop] = temp[fillLoop + 1];

Similar Messages

  • I need help getting this program to work.

    K. I don't pay much attention in my AP Comp Science Class.. but my teacher said if i can get this program to work i get an a for the semester... The program is Metrowerks Codewarrior IDE.. we are running it on windows 98 i think. She said she can't get it to compile.. so i guess it just needs to be able to input simple java programs (i.e. loops, just the regular crap) and compile them and run them...i have no clue what is wrong with it.. it could just need a patch...or we may just be going about it the wrong way...any help would be SUPER appreciated...

    K. I don't pay much attention in my AP Comp Science
    Class.. but my teacher said if i can get this programYou better did.
    to work i get an a for the semester... The program is
    Metrowerks Codewarrior IDE.. we are running it on
    windows 98 i think. She said she can't get it toAtleast be sure of the OS.
    compile.. so i guess it just needs to be able to
    input simple java programs (i.e. loops, just the
    regular crap) and compile them and run them...i have
    no clue what is wrong with it.. it could just need aEven we don't.
    patch...or we may just be going about it the wrong
    way...any help would be SUPER appreciated...Nothing in your thread really speaks of the problem. And since you mentioned homework, there's hardly anyone to be interested in that.
    Regards
    ***Annie***

  • Hello. I am running the newest version of itunes on my PC. everytime I try to copy a cd to itunes it gives me an error message that says I do not have write access for my itunes media folder or a folder within it. I cannot get this resolved.

    Hello. I am running the newest version of itunes on my PC. everytime I try to copy a cd to itunes it gives me an error message that says I do not have write access for my itunes media folder or a folder within it. I cannot get this resolved using the solution given on the error message. I have been using itunes for 4 years and have never encountered this problem until yesterday. Help would be greatly appreciated.

    Quit iTunes.
    Go to My Music folder.
    Select the iTunes folder, right click > Properties.
    Click the Security tab and make sure you have full Read/Write privileges.

  • Where can I find the plugin to open camera raw files for Nikon D810 for Photoshop CS5.1? I've looked around the site but cannot get this to work.. Thank you.

    Where can I find the plugin to open camera raw files for Nikon D810 for Photoshop CS5.1? I've looked around the site but cannot get this to work.. Thank you.

    See for yourself which version of ACR is needed for that camera’s RAW files
    http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html
    then check your version (Photoshop > About Plug-In > Camera Raw).
    Your version of Photoshop does not support that version of ACR.
    You could use the free DNG Converter.

  • How can I get this program to work -- Adobe Send or Adobe SendNow

    How can I get this program to work?  I have used Adobe SendNow successfully for several years and am on automatic renewal and getting nothing but frustration for my money!  I have been unsuccessful at sending anything in the past several months.  Today while working on a deadline and many unsuccessful attempts to upload files, I signed up for a free trial at a competitor in order to get my files sent.  Want a refund  -- or better yet, keep my money and get it to work right again.

    You can't.
    Sounds like it he gave you a stolen iPhone or at least a worthless one.

  • I won Lightroom 1.0 a few years ago at an Adobe clinic in Fremont. I have since misplaced the original disk and cannot get the program to open. It wants a serial number and I don't have one. How can I get the serial number so I can use the software?

    I won Lightroom 1.0 as a door prize a few years ago at an Adobe clinic in Fremont. I have since misplaced the original disk and cannot get the program to open. It wants a serial number and I don't have one. How can I get the serial number so I can use the software?

    Thanks for replying, Jim. I wasn't planning to use it for raw images. I shoot film, black and white, and have many negatives I want to print. I am unfamiliar with the upgrades in Lightroom. I wasn't unhappy with the version I have. It was useful for my purposes.
    Because it was a few years ago, I don't remember if I registered the product. I was able to login to my account. But could not find a path to communicate with Adobe. I will keep trying.
    Ken

  • Getting a program to compile on a mac

    hi i am really new at java, and I would like to know how to get a program to compile. The book I have mentioned something confusing about a javac file in the bin directory, and I found that in my library, But if that is the compiler then I have absolutely no idea how to make my programs compile with that.
    Also if someone could generally explain the compiling process to me that would rock
    Thanks people

    Java is an interpreted language [ like most other languages], it need the Java runtime libraries to execute and the Java compiler to translate your application's code into bits & bytes for the OS to run your application.
    all you need is to install all Java Plug ins, and your application can run in a Mac and also Linux, just as long you do not use extensive Hardware-exclusive APIS [ application programming interfaces].
    but for most of us beginners it doesn't seem to happen a lot. ;-)
    Walter_Rincon

  • I am trying to burn a .mov file from fcp xpress timeline to a dvd.  The popup message I receive prior to inserting the dvd is that I need 20.05 gb of space available on dvd (a 1.25 min). How can I get this program onto a dvd that shows a max of 8.5gb?.

    I am trying to burn a .mov file from fcp xpress timeline to a dvd.  The popup message I receive prior to inserting the dvd is that I need 20.05 gb of space available on dvd (a 1.25 min program). How can I get this program onto a dvd (where the max available gb's  for off the shelf dvds-r)  shows a max of 8.5gb?.  Please help.  Thank You!

    You have posted your question in the Final Cut  Pro X forum. You want to be in this forum instead; https://discussions.apple.com/community/professional_applications/final_cut_expr ess_hd
    Good luck.
    Russ

  • TS3649 my mac (2012) did not come with idvd.where can i get this program for download?

    My iMac os lion 10.7.2 (2012) did not come with idvd program. Where can I get this program for download?

    Hi
    If there is no iDVD on Your Mac (and it's not on newer Macs as Apple discarded it) then You need a program that can do this.
    Your Mac can burn CDs and DVDs - BUT DVD as Data-DVDs not as Video-DVDs - they need a program to be encoded and STRUCTURED as such.
    • iDVD is part of the boxed version of iLife'11 and can only be bought outside Apple as on Amazon and e-bay
    • DVD Studio pro - Part of FinalCut Studio Pro bundle - this to has expired and can only be bought second handed. (High price and tough learning Curve - but best ever done.)
    • Roxio Toast™ - Not as elegant as iDVD - but has many other positive additions (I like it as 10-Pro incl BD-component) (now version 11)
    • Burn - a free alternative I know of on internet. Very simple - Just for doing a plain Video-DVD
    Burn http://www.digital-digest.com/software/Burn.html
    • Free DVD Creator.app - free from Apple Store
    • FinalCut Pro-X which also can burn to DVD but without any nice themes.
    AppleMan1958
    You can also buy Compressor from Apple for $50 US. It will also create DVD and BluRay but without the nice themes.
    Yours Bengt W

  • HT5610 How can You authorise your Windows Vista computer??? I do not get this drop down menu nowI cannot get this here, have been trying for hours, why is this so uncooperative? My first impression of I tunes is not so good after that.

    How can you authorise your windows vista computer to play stuff you downloaded from itunes???  I cannot get this drop down menu shown on your support pages whatever I do.    I have been trying for ages.  This is not a good first impression.

    Authorize a Mac or PC
    Review the following before you authorize a computer:
    You can authorize up to five computers with your Apple ID.
    You must authorize your computer to download past purchases, use Home Sharing, or use the Automatic Downloads setting.
    You can play unprotected music that's in the AAC file format without authorizing your computer. This includes iTunes Plus tracks and content  from sources other than the iTunes Store, like your audio CDs.
    To authorize a computer, follow these steps:
    Open iTunes.
    Choose Store > Authorize This Computer from the menu bar.
    You may need to show the menu bar to see this option in Windows.     In earlier versions of iTunes, you can access this option from the Advanced menu.
    Enter your Apple ID and click Authorize.
    If your Apple ID uses an expired MobileMe account, you can still authorize your computer.
    In some cases, iTunes may ask you to authorize the computer again. iTunes should use the same authorization as before if the computer is in your  list of authorized computers.
    Learn what to do if iTunes repeatedly asks you to authorize when you try to play your content.
    http://support.apple.com/kb/ht1420
    Note : If you are Unable to see the Store Tab on your iTunes then click anywhere on your iTunes and press
    Ctrl + B key on your keyboard once and you should be able to see the Store tab in your iTunes.

  • My I-Pad is locked up with a message that I-Cloud has not  been backed up in two weeks and that the I-Pad must  be locked, connected to wireless, and plugged in.  I cannot get this message to go away or access any other parts of the I-Pad

    My I-Pad is locked up with a message that I-Clouhd has not been backed up in two weeks and that the I-Pad must be locked,  connected to wireless, and plugged in.  I cannot get this message to go away or access other parts of the I-Pad.
    I can't turn off the I-Pad either.

    U really need to call Apple support ,because only they can help you , or go the store but make sure u have an appointment ,they are always a mob scene

  • Can't get my program to compile

    I'm pretty sure I wrote this close to how it should be, but I can't get it to compile. What am I doing wrong?
    File name: TruckTest.java
    This program tests class Truck which has Vehicle as its super class
    Author: Rajan Alex
    import java.util.*;
    public class TruckTest
    public static void main(String[] args){
    Scanner keyboard = new Scanner(System.in);
    String ownerName = "Peggy", brandName = "Volkswagen";
    int towCapacity = 2000, cylinder = 4;
    double loadCapacity = 2.5;
    Truck t1 = new Truck(); // default constructor
    t1.writeOutput(); //default output
    t1.set(ownerName, brandName, cylinder, loadCapacity, towCapacity);
    t1.writeOutput();
    System.out.println("Enter make name:");
    brandName = keyboard.nextLine();
    System.out.println("Enter owner: ");
    ownerName = keyboard.nextLine();
    System.out.println("Enter number of cylinders:");
    cylinder = keyboard.nextInt();
    System.out.println("Enter load capacity:");
    loadCapacity = keyboard.nextDouble();
    System.out.println("Enter tow capacity:");
    towCapacity = keyboard.nextInt();
    t1 = new Truck(ownerName, brandName, cylinder, loadCapacity, towCapacity);
    t1.writeOutput();
    public class Truck extends Vehicle{
    private double load;
    private int tow;
    public Truck()
    load = 0;
    tow = 0;
    public class Truck(String theOwner, String theBrand, int theBanger, double theLoad, int theTow)
    theOwner = super.theOwner();
    theBrand = super.theBrand();
    theBanger = super.theBanger();
    theLoad = super.theLoad();
    theTow = super.theTow();
    public void writeOutput()
    super.writeOuput();
    public void set(String aOwner, String aBrand, int aCylinder, double aLoad, int aTow)
    aOwner = super.aOwner();
    aBrand = super.aBrand();
    aCylinder = super.aCylinder();
    aLoad = super.aLoad();
    aTow = super.aTow();
    public class Vehicle{
    private String manufacturer;
    private int cylinder;
    private String owner;
    public Vehicle(){
    manufacturer = none;
    cylinder = 0;
    owner = 0;
    public class Vehicle(String theOwner, String theBrand, int theBanger)
    owner = theOwner;
    manufacturer = theBrand;
    cylinder = theBanger;
    public void writeOutput()
    super.writeOutput();
    System.out.println("Owner: = " + owner);
    System.out.println("Manufacturer: = " + manufacturer);
    System.out.println("Number of cylinders: = " + cylinder);
    public void set(String aOwner, String aBrand, int aCylinder, double aLoad, int aTow)
    aOwner = super.ownerName();
    aBrand = super.brandName();
    aCylinder = super.cylinder();
    aLoad = super.loadCapacity();
    aTow = super.towCapacity();
    }

        // *not* public class Vehicle
    public Vehicle(String theOwner, String theBrand, int theBanger)I think you mean this to be a constructor, not a class declaration.
    It's a good idea to wrap your code in code tags when you post. As
    Described here: http://forum.java.sun.com/help.jspa?sec=formatting
    Put [code] at the start of your code and [/code] at the end.
    [Edit] You have the same problem with the Truck class.

  • Have just bought my youngest an Ipod - set up new user account on the computer, created a new email account.  However, cannot get this Ipod to connect to the Itunes store.  What am I doing wrong? Have spent hours on this!!!!

    have just bought my youngest an Ipod.  Have set up a new user accout as suggested by the man in the Apple store, got a separate email account and everything seemed ok.  HOwever, cannot get it to connec to the Itunes store so cannot redeem any vouchers.   I have now spent hours on this and am rapidly losing patience!  Can anyone help please.

    This may help.
    Can't connect to the iTunes Store
    What happens whenyou try to connect? Error messages?

  • HT4759 my ipad is giving me a message "icloud backup: this ipad hasn't been backed up in 32 wk..." but I cannot get this message to clear off my screen. I'm unable to turn the ipad on/off or do anything else with it.

    My ipad is giving me the message "this ipad hasn't been backed up in 32 weeks..." but I cannot get the message to clear off the screen. When I plug the ipad into my computer to back it up the message still will not clear off the screen and I cannot acess anything on the ipad. I cannot even power it off.

    Welcome to the Apple Community.
    You might try a forced shutdown to begin with, hold down the top and home buttons together until the device shuts down, then restart it.

  • I Have a silver w/Mirror doors dual 867 running OSX10.2. I try to install OS9.2.1 I get "THIS PROGRAM CAN NOT RUN ON YOUR COMPUTER" Message I need to be able to run Classic.

    I have a powermac Silver with mirror doors 867 dual processors running OSX 10.2 no problem there but I need to run Classic but when I try to install OS 9.2.1 I get a "THIS PROGRAM CAN NOT RUN ON YOUR COMPUTER" message.

    Your G4 (MDD) dual 867MHz model Mac requires the model-specific version of OS 9.2.2 which originally came with that machine. It can not use any other version of OS 9.
    The model-specific version of OS 9.2.2 can be installed using the original disk set which came with that machine; that disk set boots to OS X 10.2, but the installer on it can install OS 9.2.2 (Classic) as an option.
    There is no stand-alone install disk (such as a retail, i.e. white-label, CD) which can be used to install Classic on that model G4.

Maybe you are looking for