My program isn't printing to the console.....

Hi I'm new to the forums and Java. I'm trying to get my program to print to the console but nothing prints when I run it. There isn't any errors displaying so I'm guessing there is a problem with the syntax of my constructor. Did I write the methods incorrectly to where my System.out.print isn't getting the data from the rest of my program?
public class Stock {
     public static void main(String[] args) {
     public Stock() {
     public Stock(String symbol, String name){
     public String getSymbol(){
          return "ESI";
     public String getName(){
          return "ITT Technical Institute";
     public double getPreviousClosingPrice(){
          return 60.0;
     public double getCurrentPrice(){
          return 65.0;
     public void setSymbol(String symbol){
          System.out.print("Symbol: "+ symbol);
     public void setName(String name){
          System.out.print("Name: "+ name);
     public void setPreviousClosingPrice(double price){
          System.out.print("Previous Closing Price: "+ price);
     public void setCurrentPrice(double price){
          System.out.print("Current Price: "+ price);
     public double changePercent(double PreviousClosingPrice, double CurrentPrice){
          double ChangePercent;
          ChangePercent = (CurrentPrice - PreviousClosingPrice)/PreviousClosingPrice * 100;
          return ChangePercent;
}

Thanks everybody for the input. I originally had all of my methods within the main blocks, but I ended up getting three errors. I'll work on this more on Wednesday when I have some free time and post what I've corrected and changed. Again thanks.
public class Stock {
public static void main(String[] args) {
public Stock() {
public Stock(String symbol, String name){
public String getSymbol(){
return "ESI";
public String getName(){
return "ITT Technical Institute";
public double getPreviousClosingPrice(){
return 60.0;
public double getCurrentPrice(){
return 65.0;
public void setSymbol(String symbol){
System.out.print("Symbol: " symbol);
public void setName(String name){
System.out.print("Name: " name);
public void setPreviousClosingPrice(double price){
System.out.print("Previous Closing Price: " price);
public void setCurrentPrice(double price){
System.out.print("Current Price: " price);
public double changePercent(double PreviousClosingPrice, double CurrentPrice){
double ChangePercent;
ChangePercent = (CurrentPrice - PreviousClosingPrice)/PreviousClosingPrice * 100;
return ChangePercent;
}

Similar Messages

  • Changing text already printed to the console

    I've been programming as a hobby for years, but this question belongs nowhere else...
    I've used several console-interface programs that can change text that it has already printed; for instance, "Loading item ____ of 2642". Is there any way to do that in Java?

    ryanthejuggler wrote:
    I've been programming as a hobby for years, but this question belongs nowhere else...
    I've used several console-interface programs that can change text that it has already printed; for instance, "Loading item ____ of 2642". Is there any way to do that in Java?It depends on the capabilities of your console (think of a paper console, it can't change anything that is already printed). Try to google for "jcurses", it can handle those things for most consoles. A poor man's solution goes like this:
    System.out.print("foo 1\rbar 2");If you see "bar 2" your console can print simple carriage return characters and you can use that to change lines of text.
    kind regards,
    Jos

  • Center-aligned printing isn't printing in the centre.

    I keep getting a 2mm margin to the side of the document, which disturbs the layout when it's cropped. I've got 3mm of bleed set up, the document is scaled to print 100% and auto-rotate is switched on. I have tried literally every setting available in the print interface with no avail. As I'm printing manual duplex (odd pages, then even) this misalignment is a massive headache.
    I'm using Acrobat Pro, and Yosemite (most current update installed)

    Try the reset described here:
    http://kb.mozillazine.org/Problems_printing_web_pages#Reset_printer
    Check and tell if its working.

  • Print out to the console

    I'm writing a program to update something to the console. Let's say I have some fields like this:
    client1 Name1 ID1 value1
    client2 Name2 ID2 value2
    the number of client could be changed, but not much. I would like to update the value field on the console, say, every 5 seconds.
    How I could do that? It's much like some Linux/Unix program as top. System.out.println surely doesn't do the job.
    Thanks in advance for your help.

    Well, I'm new to gui application on linux. Couldyou
    tell me in a few words how to do it? Which libraryI
    should use? Thanks,Look into swing, it's a part of the standard library.Swing couldn't run on Linux/Unix without X server requirement. What I need is a terminal based application.

  • How do you locate a bug WITHOUT the emulator and the console?

    Hi.
    I'm new here and my English is not perfect but I'll try my best to explain my problem.
    I'm trying to port J2ME games to various mobile phone devices. I've no problem fixing bugs on Nokia, Sony Ericsson, or any models that offer an emulator and a console window.
    *** The problem is: In some case, The same build runs fine on Nokia/Sony emulator, but crash/freeze on LG phones.
    (this is just an example, it's not only LG phones that have this problem though)
    I believe it is possible to locate the bug by:
    - use the 'try/catch' block and print the error message using something like
    g.drawString(e.toString(),0,0,0);
    where 'g' and 'e' is a Graphics and Exception objects.
    But I wonder if there's a way to print 'everything that should be printed on the console', on the phones's display. So we don't need to manually put try/catch block.
    ok, to sum up the question.
    Question:
    1. Is there a way to print 'everything that will normally appear on the console', on the phones's screen?
    2. If no, then I'll need to try/catch the problem.
    But how can you use try/catch and "drawString" everywhere in the code?, while the actual drawing will be done only in the "paint()" method?
    I'm thinking of using 'getGraphics().drawString' when using try/catch outside the paint() method. but what's the point if the actual drawing will be done only in paint() method anyway...
    Sorry if it's a stupid question. I just started learning Java programming 3 months ago, let alone J2ME. >_<
    Thank you. =)
    /bow

    Hi Kakyoin,
    What I found was helpfull is creating a method in the MIDlet where you can display messages. For instance:
        public void createFormScreen(Alert alert) {
            // Set up the initial screen for the MIDlet
            Form formScreen = new Form("Your MIDlet name");
            firstScreen.append("Welcome to your MIDlet");
            myChoice = new ChoiceGroup(null, ChoiceGroup.EXCLUSIVE);
            myChoice.append("Your first choice", null);
            myChoice.append("Your second choice", null);
            formScreen .append(myChoice);
            formScreen .addCommand(OKCOMMAND);
            formScreen .addCommand(EXITCOMMAND);
            formScreen .setCommandListener(this);
            theListener = this;
            if (alert == null) {
                 theDisplay.setCurrent(formScreen Screen);
            } else {
                theDisplay.setCurrent(alert, formScreen);
        }So, from your constructor call the createFormScreen method, and your initial screen will be displayed.
    When an allert situation occurs in an object, call createFormScreen in a method like:
         protected void displayMessage(String title, String msg) {
              // Display the error message
              Alert error = new Alert(title, msg, null,
                        AlertType.ERROR);
              error.setTimeout(Alert.FOREVER);
              myMIDlet.createStartScreen(error);
         }Now the error message will be displayed on the screen indefenitaly. Off course your object where the error occurred should have a reference to the MIDlet object. I hope this helps you.
    Maik

  • Problem Displaying Unicode at the console

    Hello,
    What do I need to do to print out a unicode charecter which is of some other language for example ( telugu,an indian language).
    I had found out that the unicode range for telugu is 0C00 to 0C7F.
    I had tried doing char c = '\u0C10';
              System.out.println(c);
    But I could only see that a '?' symbol is being printed to the console.
    Could some one suggest an alternate or what is wrong with what I'm doing?
    Thanks in advance.

    I can install my local language font, but would it be
    helping things out?I told you, I have Japanese installed, and it didn't help me. Joni offered you a suggestion or two. Did you try them?
    because I think the unicode chraecter set relies on
    local OS! But I'm not sure.I don't know how much it depends on the OS, but it definitely depends on the capabilities of the program running. MS Word supports unicode, but that doesn't mean all Windows programs do.
    Why does'nt Windows XP Support Unicode at command
    prompt?Because cmd.exe is a very old program and probably the folks at M$ figured the way it's used it doesn't need to support unicode.
    Why do you need unicode in your command prompt?

  • Event Listner for the console

    I dont know whether this is the right forum for this question. May be this question is stupid. I am using a third part y jar file . I have a small swing application which calls this third party utility with certain arguments. This vendor utility spits out System.out.println statements to the console indicating the progress. I want to use this console print out and then update a progress bar for the swing applicatiion. Is there any way to write a console event listener for this?
    Something gets printed on the console while the java program is running. could this event be trapped?
    Thanks

    I dont know whether this is the right forum for this
    question. May be this question is stupid. I am using
    a third part y jar file . I have a small swing
    application which calls this third party utility
    with certain arguments. This vendor utility spits out
    System.out.println statements to the console
    indicating the progress. I want to use this console
    print out and then update a progress bar for the
    swing applicatiion. Is there any way to write a
    console event listener for this?
    Something gets printed on the console while the java
    program is running. could this event be trapped?
    ThanksYou can redirect stdout to a stream that you has created. Read that stream and update the progress bar.
    Kaj

  • Report not printing all the characters -main section width greater than 11"

    Hi,
    I am trying to build/modify a Report (used in Oracle Apps) which will be printed on some perforated paper. The perforated paper is little bit wider (11.25 inches) than the regular A4 size paper.
    The problem is when I print the report in Oracle Apps, the report isn’t printing all the characters at end of the page. I adjusted the page width to 11.25" in the main section's property palette, but the same thing is happening. Another point to mention is, I should use all of paper space.
    I am not sure if it’s a report builder issue or oracle apps issue.
    Any help is appreciated.
    Thanks
    Srikanth

    You must have larger margin. Try to make smaller header and/or footer.

  • I work on flash light pro and it make a print on the back of the screen of my iphone ??

    i work on flash light pro on my iphone and after i close the application ,i found that the program make a print at the back of my iphhone screen ,, it appears mainly at the blank screen , and i have pics for the application and also for the print that appear on the screen , plz reply on me and tell me how to send you the pics and i want a refund on this fault done by this application..

    i work on flash light pro on my iphone and after i close the application ,i found that the program make a print at the back of my iphhone screen ,, it appears mainly at the blank screen , and i have pics for the application and also for the print that appear on the screen , plz reply on me and tell me how to send you the pics and i want a refund on this fault done by this application..

  • I reinstalled acrobat 8 on my computer but when I try to print to a pdf it states that the program isn't activated.  I tried to install and reinstall it but it still doesn't work.

    I reinstalled acrobat 8 on my computer but when I try to print to a pdf it states that the program isn't activated.  I tried to install and reinstall it but it still doesn't work.  It shows that it is activated.  I tried to deactivate and reactivate but that doesn't help either.  Everything else seems to work.

    Hi tspcat,
    What operating system are you using, and what version? You may be running into a compatibility issue between your older version of Acrobat and the OS that you're running.
    Please let us know a bit more about your setup, so we can get to the bottom of this printing issue.
    Thanks,
    Sara

  • How to get the console output generated by a executable program?

    when I am trying to use method getOutputSteam of Process to gain the outputStream,I got nothing!
    I have also tried to use stream redirect,also no result!
    please help me! Thank you in advance!
    my main code are below:
    Process ps=Runtime.getRuntime().exec("xxx.exe");/*xxx.exe is a executable program which will generate a console with the message I want to gain.*/
    int exitVal= ps.waitFor();
    if(exitVal==0){
    BufferredReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));               String st;
    while((st = br.readLine()) !=null){
    System.out.println("write:"+st);
    }//my result show that I got nothing from the progam.
                                                           }

    I've seen this kind of problem with an offending xxx.exe. Generally it means that the program isn't flushing its output immediately, so your java program never sees it.

  • I can no longer directly print from the USPS print servelet. I now have to save the file and rename the extension to PDF load in another program to print. It used to be automatic. What happened?

    When trying to print from the USPS website (to print a label) when I click to pay and print instead of my print selection screen coming up I get the "Firefox doesn't know what to do with this" screen. THrough some web searching I found I can save the file, then change the extension to PDF and load it in another program and print but it adds two steps and is a real pain. Why would this have changed????

    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox.<br />
    Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    See also "Disable virus scanning in Firefox preferences - Windows"
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • Suddenly, my HP Laserjet 6mp won't print. The icon says it's in use (but it isn't), at other times it says it's not connected (but it is). Help!

    Suddenly, my HP Laserjet 6mp won't print. The icon says it's in use (but it isn't), at other times it says it's not connected (but it is). Help!

    That page's troubleshooting for the "Filter failed" message worked out. I consulted the Wiki before but never found that exact page. I guess I didn't use the best search criteria. Thanks for pointing it out.

  • No printing :I can't print anymore, printing the same file with another programs is ok, printing form LR: Preparing  and Printing indicatorbar in the left hand upper corner are running, but no output at all rom my printer. I have been printing before. I u

    No printing :I can't print anymore, printing the same file with another program is ok, printing form LR (in the same system and printer of course :-) ): Preparing  and Printing indicatorbar in the left hand upper corner are running and completing, but no output at all to my printer. I have been printing before. Next I upgraded to LR5.7.1 but the problem stays. Perhaps some adjustment is changed by me unintentionally, but I have no idea. Does anybody know what to check? Printing to file is also strange,the canvas only seems to accept A4, and crops any image relative to that size, so a 10x15 cm print on 10 x 15 cm paper is cropped to 10x15/2. Anybody any idea? (system win 8.1 64, printer HP B8550)

    I accidentally solved my mystery.  For some reason it was set to "print to file".  I changed it to "printer" and now I am able to print.

  • Problem with printing only 1 copy from the console on an HP photosmart 7760.

    When printing 4X6 borderless copies from a memory stick at the console the first picture correctly prints 1 copy but subsequent pictures show they are printing 1 of 2 copies. No matter how I set the number of copies this problem persists.
    I have tried to set the number of copies directly and also to the default setting. Neither works after the first picture.
    Any suggestions?
    **bleep** 

    Hello there! Welcome to the forums @UHBCDDP,
    I read about the printer issue you're having with it randomly printing out pages.
    I am really unsure of what could be causing the problem for sure, however, I have an idea that it could be related to the alignment of the unit itself. The steps I have are below and I'd suggest giving them a try to see if it helps!
    Try the steps from here: A 'Cartridge Problem,' 'Cartridge Failed,' or 'Incompatible Cartridge' Error Message Displays on the...
    I hope that helps! You can also try power resetting the printer and ensure the printer is plugged in directly to the wall outlet, avoiding power bars and surge protectors. This ensures the printer is receiving full power and may help greatly.
    Press the Power button to turn on the product.
    With the product turned on, disconnect the power cord from the rear of the product.
    Unplug the power cord from the wall outlet.
    Wait at least 15 seconds.
    Plug the power cord back into the wall outlet.
    Reconnect the power cord to the rear of the product.
    If the product does not turn on by itself, press the Power button to turn it on.
    If the troubleshooting does not help resolve your issue, I would then suggest calling HP's Technical Support to see about further options for you. If you are calling within North America, the number is 1-800-474-6836 and for all other regions: click here.
    Thank you for visiting and posting in the community, I hope you have a wonderful day
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

Maybe you are looking for

  • When I tried to add music to my IPod Classic I rec'd a mesage that it could not be synced because it cannot be read from or written to. How do I remedy this?

    I have an IPod Classic loaded with software version 1.1.2. I tried to add some music to it from my ITunes library and got a message that the IPod could not be sybced because it cannot be read from or written to. Please tell me how I can fix this issu

  • SQL Query issue with large varchar column

    I have a SQL Query (PL/SQL function body returning SQL query) which contains a large varchar column. Even if I substring the column to 30chars when it displays on the page it wraps. I have tried putting nowrap="wrap" for the HTML table cell attribute

  • Change document and triggering workflow

    Hi, There's a z-table in ERP. The requirement is to send a notification to the Java server whenever there is a change in the data content of this table. Can anyone describe the steps to be followed. Thank you.

  • Read specific XMP field

    My clients rename the PDF files that I send them for review. So when they send one back as "Approved" I need to figure out which InDesign document created the PDF. I have created a JavaScript that saves the InDesign document name into a custom XMP fi

  • Output the Texts in Accounting Documents

    We are looking for a place to hold notes related to our collection efforts.  If the credit collector does a document change on any given document, then Extras > Texts.......how can we get any of the texts to print out?  Is there a report on text obje