Checking negative even number

Write a program that is supposed to read 500 integers from user. Use a break statement to stop the reading if any negative even number is entered. Display that number
Can anyone write the pseudocode for this question?
The thing that bothers me is that a negative even number, How do I write the code to stop this one?
Can anyone also write the computation part? I'd do the remaining whole body. Thank you ( Just a rough figure will help a lot ) Thanks

xcoder wrote:
Write a program that is supposed to read 500 integers from user. Use a break statement to stop the reading if any negative even number is entered. Display that number
Can anyone write the pseudocode for this question?
The thing that bothers me is that a negative even number, How do I write the code to stop this one?
Can anyone also write the computation part? I'd do the remaining whole body. Thank you ( Just a rough figure will help a lot ) Thanks
pseudo code:
read 500 integers
  if less than 0 and even
    display number
    stopto check if negative:
if(myNumber<0){do something here}to check if even:
myTest = myInt/2;
if(myInt == (myTest*2)){do something here}BTW: there are other ways of doing this, but you should have been able to at least think of this one.

Similar Messages

  • How to add a check if entered number is even

    hi!
    I need some help. I need user to enter the size of the figure to be printed out. It has to ba an even number (otherwise it will print out with error). I need to add a check if entered size is an even number, otherwise display an error message and prompt user for entering the size again. If it is an even number the program should proceed and print out a figure. Any suggestions for the piece of code I need to add? Many thanks in advance!
    import java.util.*;
    public class Question2 {
    public int Size;
    public static void main(String[] args) {
    Scanner keyboard = new Scanner(System.in);
    System.out.print("Please enter the size of a triangle you want to print out (it has to be an even number): ");
    int Size = keyboard.nextInt();{
    if (Size%2==0){
    line(Size);
    drawtop(Size);
    middleline(Size);
    drawbtm(Size);
    line(Size);
    public static void line(int Size) {
    System.out.print("|");
    for (int i = 1; i <= Size / 2; i++) {
    System.out.print("-");
    System.out.print("*");
    for (int i = 1; i <= Size / 2; i++) {
    System.out.print("-");
    System.out.print("|");
    System.out.println(" ");
    public static void drawtop(int Size) {
    for (int line = 1; line <= Size / 2; line++) {
    System.out.print("|");
    for (int space = 1; space <= Size / 2 - line; space++) {
    System.out.print(" ");
    for (int star = 1; star <= (line * 2 + 1); star++) {
    System.out.print("*");
    for (int space = 1; space <= Size / 2 - line; space++) {
    System.out.print(" ");
    System.out.println("|");
    public static void middleline(int Size) {
    System.out.print("*");
    for (int i = 1; i <= Size / 2; i++) {
    System.out.print("**");
    System.out.println("**");
    public static void drawbtm(int Size) {
    for (int line = 1; line <= Size / 2; line++) {
    System.out.print("|");
    for (int space = 1; space <= line - 1; space++) {
    System.out.print(" ");
    for (int star = -1; star <= (2 * Size / 2 - 2 * line) + 1; star++) {
    System.out.print("*");
    for (int space = 1; space <= line - 1; space++) {
    System.out.print(" ");
    System.out.println("|");
    }

    Its really unbelievable that if you have written the code of printing triangles by yourself, how you got stuck at a trivial problem like this. Please just dont copy and paste the code for completing your assignments.
    Anyway the solution is trivial and I am giving you a work-through-:
    Think what the if condition is doing in the below code :
    if (Size%2==0){
    } It does nothing.
    You need a condition in which to print a message to ask user to input an even number and ask again if the number is not even. Doesnt this look like that u need a loop, And you dont know the how many times to loop but you do know when to end the loop. SO you need a WHILE loop with appropriate condition checked of even number.
    Now I hope you can complete the program.

  • Regex: check string for even number of a symbol

    Hi,
    for example "ass'asd'asd" is valid, but "asd'asd'asd'asd" is not, for symbol " ' ". I have tried every combination of \w, [...],',+ and nothing...
    Ideas?

    what is doing the %2 here, prome' ?If there are an even number of char symbol in String s, then s.length() - s.replace(""+symbol, "").length() will also be even. So that number mod 2 will equal zero (and return true).

  • How to find the largest odd number and smallest even number from an array

    Hello All
    I want to find out largest odd number and the smallest even number from an arry numbers? What is the best method to achieve this.
    Thanks
    Sravz

    You need to sit down and figure out an algo on how you would do it if you had to do the same thing from a blind container perspective:
    1 - collect all the items you want to look at
    2 - look at an item
    3 - is it odd?
    4 - if it is odd then check if it is larger than previously largest number
    5 - save it if it is larger
    6 - return back to 2 unless no more items
    7 - item is not odd so it must be even--is it smaller than previous
    8 - save it if it is smaller
    9 - return back to 2 unless no more items
    Now you just need to know how to check if something is even or odd: to do this you will need the modulous operator--integer division.
    Note: this all assumes that your needs are for integer type of numbers, otherwise there is not enough information to define an answer. For instance, if you are using floats at 0.5--it that even or odd? Do you consider an err factor when dealing with floats? etc...

  • I have my iphone activated and working since 3days, i purchased it from ebay with 1year warranty, when i check the serial number from Apple store at Bangalore Forum mall, they say that it does not show anything and 'OUT OF WARRANTY'.

    I have my iphone4 activated and working since 3days, i purchased it from ebay with 1year warranty, when i check the serial number from Apple store at Bangalore Forum mall, they say that it does not show anything and 'OUT OF WARRANTY'.
    Now i have a problem in it, all icons just shake and system hangs, needs restarting.

    You need to go back to the person you bought it from. Sounds like they may have sold you phone that is not as described.
    Did you check the warranty status before purchasing it?

  • My iMessage is not holding checked my phone number box in preferences

    I was using imessage perfectly. But I had to change my apple ID password and now, everytime I login in my macbook, imessage is not working, because there is no box checked, nor email address, nor my iPhone number, the one that I used to use. Now, if I want to use imessage in my macbook I have to open iMessage preferences and check my phone number.
    Does anybody knows what is happening?
    Thank you all

    Hi,
    When a Mac is "registered" for iMessages account with an Apple ID the Serial Number of the Mac is used to create an Auth Token as it is called for the Messages app that allows that Mac to work.
    I would guess a similar process of linking the Number of the iPhone to a Hardware fact about the device is also in place.
    I would contact Apple Support and check with them.  (you might need to speak to a Level 2 person as Level 1 people are script led and try to fit everything into Software or Hardware categories where as sorting and Apple ID (which the Number is in this case) is normally Free).
    I did find this iOS: Troubleshooting Messages - Apple Support
    It starts off about sorting SMS that is not working.
    This one has a bit on Unlinking an iPhone Number (with or without the iPhone) iOS and OS X: Link your phone number and Apple ID for use with FaceTime and iMessage - Apple Support
    7:55 pm      Tuesday; January 6, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Check HDD Part Number in Solaris 10 during System Running

    Dear all,
    Please help me,
    I want to check the part number of HDD of Sun Fire V890 Server during system is running by the Solaris OS command. Can we check that part number of HDD by solaris OS command?
    Or have other ways, except shutdown the system and unplug the HDD from the Server.
    Thanks you and Regards,
    Soret,

    The following command will list the vendor and product ID for each disk:
    iostat -EFrom [Sun Fire[tm] V890 Server, RoHS:YL - Full Components List|http://sunsolve.sun.com/handbook_private/validateUser.do?target=Systems/SunFireV890_R/components#Disks] you should be able to find the matching Manufacturing Part for a given vendor and product ID.

  • I bought an iphone 4s from a pawn shop,i need to check and make sure the phone is clear to be activated in my name,i was told you can check the IMEI number,i have the number,but what do i do with it?

    I bought an iphone 4s from a pawn shop,i need to check and make sure the phone is clear to be activated in my name,i was told you can check the IMEI number,i have the number,but what do i do with it?

    Who is the carrier the iPhone is carrier locked with?
    If the carrier has a blacklist for lost/stolen cell phones, it would be the carrier you need to contact.

  • System don`t check an order number for CO account assignment

    hi,
    I have this problem. When I creta a sales order in CRM and then system creates as a follow up document a sales order in SD system don`t check an order number for CO account assignment. If I want to create a sales order not as a follow up document, but directly in transaction VA01 and I use exactly the same data system gives me a message " The CO account assignment object belongs to company code X, not Y
    You want to make a posting in company code Y.
    At the same time, a CO account assignment object was specified that is assigned to company code X.
    This is account assignment object with object type ORD, and object key 1xxxxxxxxxxx...".
    My question is why system don`t check order number when a sales order in SD is created as a follow up document and what should I do to correct this.
    Regards,
    Mateusz

    Check note
    a)  352261  or
    b)  557562
    thanks
    G. Lakshmipathi

  • Check on PF Number

    Dear Experts,
    Currently, there is no check on PF Number alloted to employees. i.e., the same number is allowed to enter for any number of employees.
    Please let me know if there is any possibility to provide a check?
    Regards
    ...Sadhu

    i dont think this is possible at configration level
    here
    PF number will not be allocated as and when the Employee gets joins in the organisation so it may take some time to get the PF number
    and another thing is the PT IT0587 is with TC01  so pls chck
    and i think this can be possible only with ABAP development
    Lts wait for other view

  • SC still visible in check status even after GR and Invoice

    Hello all,
    We are on SRM 4.0 SP 4.0.
    Normally SCs for which GR and invoice has been done should not be visible in the SC check status application if you dont select the "Include completed shopping carts". TBut in some cases though we have selected the "Delivery Completed" indicator in backend PO but still there are some shopping carts still visible in check status application in SRM. The values for the GR and invoice should have status of "Fully confirmed".
    For such shopping carts when i manually run the report BBP_GET_STATUS_2 it replicates the correct status and the SCs disappear from the SC check status application.The BBP_GET_STATUS_2 and the CLEAN_REQREQ_UP programs are scheduled every 5 mins.
    Any hints or ideas will be much appreciated.
    Best regards,
    Sambit

    Hi Sambit,
    In Check status, in extended search check whether the incuding completed shopping carts check box was checked or not.
    If the check box was checked then even the completed shopping carts get displayed.
    Please let me know if this is not the case.
    Rgds,
    Teja

  • Check duplicate asset number during MIGO

    Hi MM/Abap Gurus ,
    What user exit can be used to check duplicate asset number during GR. E.g: I have a PO with same asset number for item line 1 and 2. What user exit can be used to set warning msg if duplicate asset number exits during MIGO. Please advise if there any user exit can be used for my requirement?
    Thanks
    Mitra

    Hi Puspha,
    Actually, the scenarios as below:
    1. PO created with 1 line item with Acc Assign Cat = A and multiple account assignment. Therefore, under the account assignment tab there are duplicate asset number inputted.
    2. Hence, when do GR, the system should prompt warning message " Duplicate asset number exists".
    Above are the requirement. I need any user exit that I can use in MIGO, where there is checking on duplicate asset number or during the sving of MIGO, I could inforce a logic on the checking.
    Your help appreciated.
    Thanks

  • How could it be possible to check the product number here to find that it is not factory reject?, How could it be possible to check the product number here to find that it is not factory reject?

    How could it be possible to check the product number online to find that it is not factory rejection?
    My product is Iphone 5 by the way.

    <https://selfsolve.apple.com/agreementWarrantyDynamic.do>

  • How to check credit card number when clicking Update order

    Hi Experts,
    I need to check credit card number when clicking Update order.
    I put  if(document.forms['order_positions'].elements['nolog_cardno'].value == "") in submit_refresh function,  but get "document.forms.order_positions.elements.nolog_cardno.value is null or not an object" error.  Any advises?
    Thanks, Jin

    Try like this
          if ( document.forms['order_positions'].elements['nolog_cardno[0]'].value == "" )

  • Field exit for checking if tax number is unical in vendor master.

    Hi,
    is there a field exit that checks if tax number is unical in vendor master?
    Best regards

    Swamy,
    As you've pointed out, you already know that path. I'd recommend stating all that you've already tried and ruled out while posting a query here. It'll help people putting in effort that won't be helpful to you.
    Coming back to your query, there is obviously no way to introduce email ID as a sensitive field. However, there's nothing stopping you from using a little creativity here. This solution is not exactly direct, but I believe it is achievable. Here are your components:
    Have a look at enhancement SAPMF02K (t.code SMOD). Look at the component FM - EXIT_SAPMF02K_001.
    From table LFA1, get LFA1-ADRNR. Go to table ADR6 (SMTP Numbers (Business Address Services)).
    In ADR6, field SMTP_ADDR is email ID.
    You can designate a field you don't currently use as always = email ID field content on vendor master screen. This proxy field can get it's value inside the user exit I've mentioned above, and you can find the email ID using the logic I've mentioned above. Ensure that this proxy field can be designated a sensitive field. That's it!
    Now, everytime a user changes the email ID, your proxy field gets changed, and thus invokes the Senstive Field rule.
    I've not used this myself, but believe it should work.
    Remember to assign points if found useful.
    Regards
    Gulshan

Maybe you are looking for

  • Creative and the Trade Descriptions

    I bought a Creative Zen Micro about 2 months ago. of the reasons i bought it as opposed to the Ipod was so i could synch my Outlook contacts / calendar with the device. With the latest firmware for MTP support 2.002 and an XPsp2 machine running outlo

  • Print content of XML string to a spool

    Hello, In my program I have an XML string. I can display this on the screen using FM DISPLAY_XML_STRING. The problem is that when running the program in background, it does not generate a spool. Is there a standard way (function module or class) whic

  • When I first installed my HP 7510 All in one it would automatica​lly print both sides not now

    When I first installed my HP 7510 onto my HP Pavillion Slimline it would print both sides automatically and wait for the ink to dry before taking the paper back in to print the other side. Now if I want both side printing I have to take the paper out

  • Firefox 30: still crashes with or without addons enabled

    I have tried everything mentioned in every other forum, i have created another profile, no fix, i have disabled all add ons no fix, it still crashes in safe mode, i have uninstalled and reinstalled fifefox 30: no fix, i have updated drivers , I have

  • NTP over a cluster

    I haven't been able to find a good source to explain the errors I have been getting with NTP. Following the Network services guide, I have setup a headnode as an NTP server. It gets it's own time sync'd from time.apple.com and has a few other Xserve