This program doesn't display the results :-(

this program should output the sum,difference,product and quotient of two numbers.
i guess the computeQuotient is the wrong part..
import java.util.*;
public class MethodExample2
     static Scanner get = new Scanner(System.in);
     public static void main(String[] args)
          double sum,difference,product,quotient;
          double n1,n2;
          System.out.print("Enter the first number: ");
          n1 = get.nextInt();
          System.out.print("Enter the second number: ");
          n2 = get.nextInt();
          sum = computeSum(n1,n2);
          difference = computeDifference(n1,n2);
          product = computeProduct(n1,n2);
          quotient = computeQuotient(n1,n2);
          System.out.print("Sum: " + sum);
          System.out.print("\nDifference: " + difference);
          System.out.print("\nProduct: " + product);
          System.out.print("\nQuotient: " + quotient);
          System.out.println();
     public static double computeSum(double num1,double num2)
          return num1 + num2;
     public static double computeDifference(double num1,double num2)
          return num1 - num2;
     public static double computeProduct(double num1,double num2)
          double res = 0.0;
          for(double ctr = num1;ctr > 0; ctr--)
                    res = num2 + res;
          return res;
     public static double computeQuotient(double num1,double num2)//i guess this is the wrong part
          double res, ctr;
          for(ctr = 1; ctr >= 0; ctr++)
               res = num1 - num2;
               num1 = res;
          return ctr;
}

Dear Sir:
The ArithmeticException is RuntimeException, therefore it is unchecked exception.....
Here is my dumb program for your reference....
import java.util.*;
public class ScannerExp{
     static Scanner get = new Scanner(System.in);
     public static void main(String[] args){
     double sum,difference,product,quotient;
     double n1,n2;
     System.out.print("Enter the first number in double format: ");
     n1 = get.nextDouble();
     System.out.print("Enter the second number in double format: ");
     n2 = get.nextDouble();
     sum = computeSum(n1,n2);
difference = computeDifference(n1,n2);
     product = computeProduct(n1,n2);
     quotient = computeQuotient(n1,n2);
     System.out.print("Sum: " + sum);
     System.out.print("\nDifference: " + difference);
     System.out.print("\nProduct: " + product);
     System.out.print("\nQuotient: " + quotient);
     System.out.println();
     public static double computeSum(double num1,double num2)
          return (num1 + num2);
     public static double computeDifference(double num1,double num2)
          return (num1 - num2);
     public static double computeProduct(double num1,double num2){
          return (num1*num2);
     public static double computeQuotient(double num1,double num2){
return (num1 / num2);
use
jacvac ScannerExp.java
java ScannerExpthen input the number you want to compute....
Hope it is half right....

Similar Messages

  • While Installing this error is coming This Program can not display the pag

    When I Try to Install SAP B1 8.8 on Win server 2008.
    I am receiving this message.
    This Program can not display the page
    The website is encountering Problem
    There might be a typing error in the address
    At the time of Installation which site we need to access.
    My Internet is working.
    Still i am facing this Problem please suggest me what should I do.

    HI Ram ,
    Internet is not required while Installation .
    Go through :
    Re: SAP Business Installation
    Thanks
    Ashish

  • Layout - This Program can not display the webpage

    Hi Experts,
    I am trying to create adobe forms in Webdynpro ABAP, for that I created a Webdynpro component and then view in it and created the required attributes and nodes and the pdfsource as xstring type.
    When I go to Layout tab it showing "This Program can not display the webpage" and in route element container I created an element and gave as of Interactive forms but the system is not creating any interface nor going into adobe live cycle designer.
    Is it the problem with the Live Cycle Designer or what exactly I have to do now.
    Please help me out.
    Thanks,
    Praveen

    Hi.,
    This seems that u didnt maintained host entries.,
    Click Run -> enter drivers -> goto etc folder -> double click on hosts file -> open with note pad.
    there u need to enter the host entries., like .. 192.....<server_address> <tab> <domain> <tab> <host>
    ask ur basis team., they will configure that..,
    hope this helps u.,
    reply if u need some more clarifications.,
    Thanks & Regards
    Kiran

  • Please explain what this program doing- I see the results but don't underst

    public class Mystery2{
    public static void main(String []args){
    int count = 1;
    while (count <= 10){
    System.out.println(count % 2==1? "****":"++++++");
    ++count;
    }//end while
    }//end main
    }//end class

    Hello! First of all - where did you find this code (just for information, so it's easier to answer the question)
    Secondly, pls be so kind as to use code tags. Here's the same program, reformatted and in code tags:
    public class Mystery2
        public static void main (String [] args)
            int count = 1;
            while (count <= 10)
                System.out.println (count % 2 == 1 ? "****" : "++++++");
                ++count;
            }//end while
        }//end main
    }//end class

  • I recently brought a HD PVR, i put in the disk to install the hard drive and it said " This program doesn't support DOS Mode! how do i get out of DOS Mode?? Please Help

    I recently brought a HD PVR, i put in the disk to install the hard drive and it said " This program doesn't support DOS Mode! how do i get out of DOS Mode?? Please Help

    What exactly are you trying to do? PVRs are for recording from TV not computers.
    Either way, if it's complaining about DOS mode, it's Windows oriented software and not Mac compatible.

  • Convert this query to ABAP and display the results

    Hi Everyone,
    I have a sql query in native sql (oracle). I want execute it in ABAP editor and display the results.
    I need to get this to an internal table and display the results. How do i write the script any help will be great use to me.
    Here is the query:
    <i> select (select decode(extent_management,'LOCAL','*',' ') ||
                   decode(segment_space_management,'AUTO','a ','m ')
              from dba_tablespaces where tablespace_name = b.tablespace_name) || nvl(b.tablespace_name,
                 nvl(a.tablespace_name,'UNKOWN')) name,
           kbytes_alloc kbytes,
           kbytes_alloc-nvl(kbytes_free,0) used,
           nvl(kbytes_free,0) free,
           ((kbytes_alloc-nvl(kbytes_free,0))/
                              kbytes_alloc)*100 pct_used,
           nvl(largest,0) largest,
           nvl(kbytes_max,kbytes_alloc) Max_Size,
           decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used from ( select sum(bytes)/1024 Kbytes_free,
                  max(bytes)/1024 largest,
                  tablespace_name
           from  sys.dba_free_space
           group by tablespace_name ) a,
         ( select sum(bytes)/1024 Kbytes_alloc,
                  sum(maxbytes)/1024 Kbytes_max,
                  tablespace_name
           from sys.dba_data_files
           group by tablespace_name
           union all
          select sum(bytes)/1024 Kbytes_alloc,
                  sum(maxbytes)/1024 Kbytes_max,
                  tablespace_name
           from sys.dba_temp_files
           group by tablespace_name )b
    where a.tablespace_name = b.tablespace_name order by 1;
    </i>
    Thanks,
    Prashant.

    Hi Prashant,
    Native SQL commands in ABAP are placed between EXEC SQL and ENDEXEC. You can place all your statements in between these EXEC SQL and ENDEXEC in a report.
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.
    Check this link to know about Native SQL
    http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm
    Thanks,
    Vinay

  • Re: my notebook doesn't display the red color

    I think I have the same or a similar problem.  I have a AMD A4-6210APU with radeon r3 graphics 1.8 ghz running 64 bit windows 8.1.
    Since updating the graphics driver last week I have noticed the colour red seems more pink or purple.  This is particularly notable as a lot of my buttons and icons contain scartlet as the principle colour.  I only purchased the laptop in August so I doubt this is due to a deteriation of the hardware and therefore seems to be an issue with either the display driver or the display settings.
    I have attempted to rectify the problem by resetting the display settings to default.
    This partidular model does not appear to have any contrast settings built into the controls, therefore I have no way to adjust the colours manually.

    Hello @pittstop,
    Welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the HP Forums I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More.
    I have read your post on how your notebook doesn't display the red color on the screen, and I would be happy to assist you in this matter!
    To ensure that your system is installed with the correct graphics software, I recommend installing the original software and hardware drivers that first came with your computer. This can be done by following the steps in this document on Using Recovery Manager to Restore Software and Drivers (Windows 8). Once the software is installed, please update the chipset and graphics drivers Using HP Support Assistant (Windows 8).
    I would also encourage you to post your product number for your computer. Below is a is an HP Support document that will demonstrate how to find your computer's product number. In addition, it will also help if you indicate whether your operating system is 32 or 64 bit. The more information you can provide, the better!
    How Do I Find My Model Number or Product Number?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    Please re-post with the results of your troubleshooting, as well as the requested information above. I look forward to your reply!
    Regards
    MechPilot
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks” for helping!

  • WEB.SHOW_DOCUMENT sometimes doesn't display the generated PDF file

    Hi all,
    I'm using the following code to generated my report from Forms:<br><br>
    V_REPORT_ID := FIND_REPORT_OBJECT(V_REPORT_NAME);
    V_REPORT_SERVER_JOB:= RUN_REPORT_OBJECT(V_REPORT_ID,P_LIST);
        V_JOB_ID := substr(V_REPORT_SERVER_JOB,length(:GLOBAL.REPORTS_SERVER)+2,length(V_REPORT_SERVER_JOB));
        V_REPORT_STATUS := REPORT_OBJECT_STATUS(V_REPORT_SERVER_JOB);
    LOOP
       IF V_REPORT_STATUS = 'FINISHED' THEN          
          V_TMP_PDF := :GLOBAL.APACHE_HTML_FOLDER ||'rpt'|| V_JOB_ID  ||'.pdf' ;
         COPY_REPORT_OBJECT_OUTPUT(V_REPORT_SERVER_JOB, V_TMP_PDF );
        WEB.SHOW_DOCUMENT(:GLOBAL.AS_HOME_URL ||  'rpt'|| V_JOB_ID  ||'.pdf' ,'_BLANK');     
        END IF;
    END LOOP; <br><br>
    Everything works fine except the WEB.SHOW_DOCUMENT part. In some clients, this command does what it required from it and opens a new browser window with the PDF report displayed on it. In some other clients, this command does nothing: now window dispalyed. When I refer to the Application Server, I see the PDF report successfully generated there. When I put the URL of the generated report manually in the browser address, I can see the report.
    <br><br>
    <b>Why the WEB.SHOW_DOCUMENT doesn't display the generated PDF report in some clients?</b>

    I agree with the previous 2 posters.
    Also firefox and ie handle it differently. Make sure you test on what your clients use.
    Sometimes acrotray.exe is completely retarded and doesn't work.

  • Every time I try to access the ASPX pages, the browser doesn't display the pages. Instead, a popup box asks if I want to open or save

    every time I try to access the ASPX pages, the browser doesn't display the pages. Instead, a popup box asks if I want to open or save

    What site is doing this? 99% of the time it is a problem with the headers sent from the web server.

  • Verify_function doesn't display the error messge in oracle forms

    We are planning to use the verify_function to validate the password when user password is expires.
    The users are using Forms 6i on web.
    When I set the profile to user verify_fucntion and then try to change the password with the default password change window , it doesn't display the error message if the crieteria doesn't match. Instead it just clears the screen. So the user doesn't get any idea what's going on.
    has anybody seen this. We are trying to utilize the default password change functionality instead of coding our own.....in forms
    Thanks,
    Dj

    It can be that the spry:content does not support the function::<syntax> or that your impelementation is wrong. You can try this:
    spry:content="function::FormatDate"
    Like you would implement the function statement in the spry:if statements.
    If that doesn't do the trick you need to modify the SpryData.js if you need this kind of support.

  • I want a stamp to write to the file metadata and be able to display the result in windows explorer.

    I want a stamp to write to the file metadata and be able to display the result in windows explorer. I have read PDF Stamp Secrets and can write to Custom Metadata but don't know how to display that custom field in explorer. Can I have the stamp write to a standard (non-custom) metadata field? Or, how do it get the custom field to display in explorer? Windows is pretty stingy with the file details it displays for PDF files, in fact there are no editable fields provided (like are available for Office files).   I want this to work for multiple users hopefully without having to get the IT group involved to make (or allow) system modifications to make this work. Any ideas? Thank you.

    Metadata for Windows Explorer is tagged with different names than the metadata for PDFs. Acrobat cannot copy the metadata to the tagged items of the file header.
    There are tools like EXIFTool that can manipulate the data as necessary. Phil Harvey also provides the details about the file types and their metadata tags and values so you should be able to map the tags that need to be updated.

  • Some methods are displaying the result on the server instead on the client.

    When I test (form SeatReservationClient class) the method sri.showReservations() located in SeatReservationClient class the results are being displayed on the server side instead on the client but the method sri.numReservations() is displaying the result as i want it i.e. on the client. Please can anyone help me (as always on this forum) find a solution to this problem and display the results correctly?
    I have 5 classes:
    Interface
    public interface SeatReservationInterface extends java.rmi.Remote
         public boolean isReserved(int row, int seat) throws java.rmi.RemoteException;
         public boolean reserve(int row, int seat) throws java.rmi.RemoteException;
         public boolean cancel(int row, int seat) throws java.rmi.RemoteException;
         public int numReservations() throws java.rmi.RemoteException;
    public void showReservations() throws java.rmi.RemoteException;
    Implementation
    public class SeatReservationImpl extends java.rmi.server.UnicastRemoteObject implements SeatReservationInterface
         private Seat[][] theatre;
         * Implementations must have an explicit constructor in order to declare the RemoteException
         * exception.
        * Theatre constructor makes a new movie theatre with numRows rows and numSeats
        * seats (chairs) in each row. All seats are unreserved (unoccupied) in the beginning.
        public SeatReservationImpl(int numRows, int numSeats) throws java.rmi.RemoteException
              theatre = new Seat[numRows][numSeats];
              for(int row = 0; row <theatre.length; row++)
              for(int col = 0; col<theatre[row].length; col++)
              theatre[row][col] = new Seat();
        * The method returns true if the seat at location (row, seat) is reserved.
        * The method returns false in all other cases.
        * Be careful that row numbers run from 1 to numRows, and seat numbers from
        * 1 to numSeats.
         public boolean isReserved(int row, int seat) throws java.rmi.RemoteException
             return theatre[row-1][seat-1].isOccupied();
        * Books the seat at location (row, seat) and returns true if that seat is available.
        * Returns false if that seat is already reserved.
         public boolean reserve(int row, int seat) throws java.rmi.RemoteException
              return theatre[row-1][seat-1].occupy();
        * Cancels a seat reservation at location (row, seat) is that seat was booked, and returns
        * true in that case. The method returns false if that seat had not been reserved.
         public boolean cancel(int row, int seat) throws java.rmi.RemoteException
              return theatre[row-1][seat-1].release();
        * Returns the number of reserved seats.
         public int numReservations() throws java.rmi.RemoteException
              int count = 0;
              for(int i = 0; i < theatre.length; i++)
              for(int j = 0; j < theatre[j].length; j++)
              if(theatre[i][j].isOccupied())
              count++;
              return count;
    * Prints an overview over all reservations. Reserved seats are shown as "*", available seats
    * as "-". For each row the row number is shown, then a couple of blanks, and then the
    * reservations. An example is
    * 8 -----****----
    * 7 ---**---**---
    * 6 ----***------
    * 5 -------------
    * 4 -------------
    * 3 ----------***
    * 2 **-------
    * 1 -------------
    public void showReservations() throws java.rmi.RemoteException
              for(int row = theatre.length-1; row>=0; row--)
                   System.out.print((row+1) + "\t");
                   for(int j = 0; j<theatre[row].length; j++)
                   if(theatre[row][j].isFree())
                   System.out.print("-");
                   else
                   System.out.print("*");
                   System.out.println();
              return;
    [i]Server import java.rmi.Naming;
    public class SeatReservationServer
    public SeatReservationServer()
    try
         SeatReservationInterface sri = new SeatReservationImpl(10, 5);
         Naming.rebind("rmi://localhost:1099/SeatReservationService", sri);
    catch (Exception e)
    System.out.println("Trouble: " + e);
    public static void main(String args[])
    new SeatReservationServer();
    Client
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import java.net.MalformedURLException;
    import java.rmi.NotBoundException;
    public class SeatReservationClient
        public static void main(String[] args)
            try
                   SeatReservationInterface sri = (SeatReservationInterface) Naming.lookup("rmi://localhost/SeatReservationService");
                   /* Make two reservations */
                   System.out.println("Reservations:");
                   System.out.println("1,2");
                   System.out.println("1.3");
                   System.out.println("1,4");
                   sri.reserve(1,2);
                   sri.reserve(1,3);
                   sri.reserve(1,4);
                   System.out.println("The Seat is occupied - " + sri.isReserved(1,2));
                   System.out.println("The Seat is occupied - " + sri.isReserved(1,3));
                   System.out.println("The Seat is occupied - " + sri.isReserved(1,4));
                   /* Show the theatre */
                   sri.showReservations();
                   /* Release a seat that had been booked */
                   System.out.println("Release seat row 1 seat 2");
                   sri.cancel(1,2);
                   System.out.println("The Seat is occupied - " + sri.isReserved(1,2));
                   /* Show the number of total reservations and the theatre */
                   System.out.println("Number of reservations: " + sri.numReservations());
                   sri.showReservations();
            catch (MalformedURLException murle)
                System.out.println();
                System.out.println("MalformedURLException");
                System.out.println(murle);
            catch (RemoteException re)
                System.out.println();
                System.out.println("RemoteException");
                System.out.println(re);
            catch (NotBoundException nbe)
                System.out.println();
                System.out.println("NotBoundException");
                System.out.println(nbe);
            catch (java.lang.ArithmeticException ae)
                System.out.println();
                System.out.println("java.lang.ArithmeticException");
                System.out.println(ae);
    Class containing instance methods
    public class Seat
    private boolean occupied;
         * Constructors:
         Seat()
         Seat(boolean o)
              occupied = o;
         * Instance methods:
         public boolean isFree()
              return !this.occupied;
         public boolean isOccupied()
              return this.occupied;
         public boolean occupy()
              if(occupied)
              return false;
              else
                   occupied = true;
                   return true;
         public boolean release()
              if(!isOccupied())
              return false;
              else
              occupied = false;
              return true;
    }

    Your code is working as expected. The server executes System.out.println in showReservations() and this comes out on the server console. The client executes System.out.println() after calling numReservations and this comes out at the client. Any other expectations are misplaced.

  • Display the results with a delay between each

    I am very new to java and using NetBeans 5.
    I want to display the results of different methods in a JtextArea with a delay between each output to the JtextArea.
    I have tried Timer with no success.
    Please could some one point me in the right direction
    Thanks

    I have tried Timer with no success.Such a vague description of the problem its to recommend an approach.
    Using a Timer is always a good approach.
    Otherwise make sure you execute the long running code in a Separate Thread and then use SwingUtilities.invokeLater(..) when you need to update the GUI. Here is a simple example using this approach:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=621226

  • How to Read the one Source Column data and Display the Results

    Hi All,
         I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
    Ex:
    Pr_ProjectType
    AD,AM
    AD
    AM
    AD,AM,TS,CS.OT,TS
    AD,AM          
    like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
    4.AD,AM,TS,CS.OT,TS in this string we need AD,AM  only.
    this logic we need we have thousand of data in the table.Please help this is urgent issue
    vasu

    Hi Vasu,
    Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
    are two approaches for your reference:
    Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
    for the custom function is as follows:
    CREATE FUNCTION dbo.udf_GetNumeric
    (@strAlphaNumeric VARCHAR(256))
    RETURNS VARCHAR(256)
    AS
    BEGIN
    DECLARE @intAlpha INT
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
    BEGIN
    WHILE @intAlpha > 0
    BEGIN
    SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
    END
    END
    RETURN ISNULL(@strAlphaNumeric,0)
    END
    GO
    The SQL commands used in the OLE DB Source is like:
    SELECT
    ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
    FROM MyTable
    Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
    characters to the corresponding substring. The script is as follows:
    using System.Text.RegularExpressions;
    Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
    References:
    http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/ 
    http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html 
    Regards,
    Mike Yin
    TechNet Community Support

  • How to create a task list view in c# that doesn't display the timeline

    How can I create a view for a task list using c# that doesn't display the timeline.  I want to do this using server side code but I can't seem to find a view property that will hide the timeline.  I know how to do it manually through the UI but
    I need to automate it.
    Caroline

    Hi Garoline,
    We can set ViewData of the view to empty to achieve your requirement. The following code snippet for your reference:
    using (SPSite site = new SPSite("http://sp2013sps/"))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["TaskList"];
    SPViewCollection allviews = list.Views;
    string viewName = "Test View";
    System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
    viewFields.Add("Checkmark");
    viewFields.Add("LinkTitle");
    viewFields.Add("Due Date");
    viewFields.Add("Assigned To");
    string myquery = "<where><gt><fieldref name='ID' /><value type='Counter'>0</value></gt></where>";
    allviews.Add(viewName, viewFields, myquery, 100, true, false);
    SPView view=list.Views[viewName];
    view.ViewData = "";
    view.Update();
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for

  • How to remove all calendars from OSX

    I have a MBP with OSX Lion. iCloud all set up. I want to delete all local calendars from MBP so I can run a sych with iCloud so I don't duplicate events. How to I delete all local calendars so my iCloud sync stays clean. I'm surprised that in additio

  • EJB 3.0 and jndi lookup (simple question)

    hi all, i am newbie on Weblogic Application Server and i have some issues, i have weblogic application server 10.0, also i have oracle timesten in-memory database, i have configured datasource and deploy my ejb 3.0 application, but i could not done j

  • The album artowrk won't display on my iPod.

    To put it basically, the album artwork does not display on my iPod any more. It is shown in iTunes, and when I right-click on a song and look at its "info" It shows the artwork. I have tried deleting all of the songs and re-adding them from their ori

  • Some Programmes are NOT responding all the time.

    Hi I have had a clean sweep of my computer and just recently some programmes such as Skype and WebplusX5 are not responding. This isnt just a one off thing it happens all the time. I was wondering if anybody could help me into finding a solution.  Th

  • Where can I get Internet Toolkit for LabVIEw v.5.1

    I would like to start Internet (web-based) application and using labVIEW v.5.1 now. So how can I get Internet Toolkit for that version and where can I get manual for that purpose.