Times Tables program - validation problem

I am trying to validate an entry so that it only is between 1 - 12 (for times tables). Program is running but not working properly.
Here is code:
class assign2{
     public static void main(String[]args){
          int table;
          int lines;
          char type;
          do
          System.out.println("Please enter the times tables required (1 - 12)");
          Keyboard.skipLine();
          table = Keyboard.readInt();
          if (table < '1' || table > 12)
          System.out.print("Error - Invalid entry !! ");    // (C)  Error msg if invalid
        }while (table >= '1' || table <= 12);
}

use 1 and not '1'. The latter is a char with the value 31 I think.

Similar Messages

  • Help with calculation code!! for Times tables program

    I am creating a times tables program that lets the user select the Times tables, number of lines required and the type of table (multipy, addition etc).
    So if user selects 12 times tables and 4 lines it should look like this on the screen:
    12 x 1 = 12
    12 x 2 = 24
    12 x 3 = 36
    12 x 4 = 48
    and so on...
    Problem is that when I pass the info to the procedure in the below code I am not sure what I need to do to replicate the above.
    Appreciate some ideas! Here is code so far:
    class assign2{                                                                                                         // Begin Class
         public static void main(String[]args){                                                                      // Begin Main
              int table;                                                                                                    // Declare a variable
              int lines;                                                                                                    // Declare a variable
              char type;                                                                                                    // Declare a variable
              do                                                                                                              // Begin do - while loop
                   System.out.println("Please enter the times tables required (1 - 12)");
                   Keyboard.skipLine();
                   table = Keyboard.readInt();
                   if (table < 1 || table > 12)
                   System.out.print("INVALID ENTRY - Please try again and enter between 1 and 12");    // Error msg if invalid
                   System.out.println();
            }while (table < 1 || table > 12);                                                                      // End do - while loop
            do                                                                                                              // Begin do - while loop
                 System.out.println("Please enter the number of lines required (1 - 12)");
                 Keyboard.skipLine();
                 lines = Keyboard.readInt();
                   if (lines < 1 || lines > 12)
                   System.out.print("INVALID ENTRY - Please try again and enter between 1 and 12");    // Error msg if invalid
                   System.out.println();
            }while (lines < 1 || lines > 12);                                                                      // End do - while loop
              do                                                                                                              // Begin do - while loop
                   System.out.println("Please select the table type from one of the following (A - D): ");
                   System.out.println();
                   System.out.println("A: Multiplication Tables");
                   System.out.println("B: Division Tables");
                   System.out.println("C: Addition Tables");
                   System.out.println("D: Subtraction Tables");
                   Keyboard.skipLine();
                   type = Keyboard.readChar();
                   if (type != 'a' && type != 'b' && type != 'c' && type != 'd')
                   System.out.print("INVALID ENTRY - Please try again and enter either A - B - C - D");      // Error msg if invalid
                   System.out.println();
              }while (type != 'a' && type != 'b' && type != 'c' && type != 'd');                              // End do - while loop
                   switch(type){                                                                                          // Begin Switch
                        case 'a': getMultiply(table, lines); break;
                        case 'b': getDivide(); break;
                        case 'c': getAdd(); break;
                        case 'd': getSubtract(); break;
                   }                                                                                                         // End Switch
       //Procedure to calculate the Multiplication Times Tables//
              static void getMultiply(int table, int lines){
       //Procedure to calculate the Division Times Tables//
              static void getDivide(){
                   System.out.println("This is divide!!!");
       //Procedure to calculate the Addition Times Tables//
              static void getAdd(){
                   System.out.println("This is Add!!!");
       //Procedure to calculate the Subtraction Times Tables//
              static void getSubtract(){
                   System.out.println("This is Subtract!!!");
         }                                                                                                              // Ends Main
    }                                                                                                                   // Ends Class

    I wasn't being rudeYes, you were.
    or expecting an immediate
    responseYour posts suggested otherwise.
    I was simply expressing how I was stuck with
    the problem.That's not relevant to anybody here. What is relevant is your specific question, which I don't see in your initial post. Just "how do I do this?"
    You know what, I am a beginner to this programming
    and it's people like you with your smug attitute and
    'KNOW IT ALL' behaviour that puts people like me off
    even looking to go down this road as a career.Given your attitude so far, I doubt you'll be missed.
    So, why don't you stop acting like a spoilt little
    child and stop pretending like you own this forum.Flounder was right: Nobody here likes that demanding, "Help me now!" attitude. Coupled with the fact that your question is very vague and the tone of your subsequent posts, you're not doing much to encourage anyone to volunteer their time to help you.
    Not to mention that posting the same question multiple times is rude and annoying. It's very irritating to spend time answering a question, only to find out somebody else has already answered it.

  • Programming a times table with FOR, WHILE & DO WHILE STATEMENTS

    Guys,
    Help me, I have tried hard, but I didn't find the answer, my problem is that I got difficulties in doing a times table with the FOR, WHILE, and DO WHILE STATEMENTS just using a single index or a single variable.
    Guys, is it possible to program a times table with these conditions all together in the same code???
    Do I await your suggestions?
    Ps: Below, the attempt that I did, but I was not successful.
    import javax.swing.JOptionPane;
    public class tab
    public static void main(String args[])
    int i;
    String TimesTable= "";
    int result=0;
    do
    for (i=0;i<=10;i++)
    result=i*1;
    TimesTable +="\n" + i + "x" + i + "=" + result;
    //JOptionPane.showMessageDialog(null, "Times tables of " + i + TimesTable);
    // TimeTable="";
    // i=0;
    // i=i+1;
    // i=0;
    while(i<=10)
    i=i+1;
    // System.out.println("2 x "+i+"="+2*i);
    // i--;
    }while(i!=0);
    JOptionPane.showMessageDialog(null, "Times Table of " + i + TimesTable);
    TimesTable="";
    }

    You can use the if block "if(i%10==9)" in this case.

  • I have recently had problems in getting my Adobe Premiere Elements 10 to run. One of the gentlemen was able to take over control of my computer, and got it working for me, however since that time the program will sometimes open but most times it just free

    I have recently had problems in getting my Adobe Premiere Elements 10 to run. One of the gentlemen was able to take over control of my computer, and got it working for me, however since that time the program will sometimes open but most times it just freezes the computer and I have to shut it down and re open without any success with opening the elements program.
    Can you help

    Sosure
    What computer operating system is your Premiere Elements 10 running on?
    What video card/graphics card does your computer use? NVIDIA GeForce? If so, please read the Announcement about the Premiere Elements 10 NVIDIA GeForce issue which is found at the top of this web site. Does that apply to you? The explanation for the situation and the fix (roll back of the driver version) are all included in that Announcement.
    We need to rule in or out this factor at the onset before we get to other questions
    a. non NIVIDIA video card/graphics card driver
    b. project preset and properties of source media
    c. computer details
    More later.
    We will be watching for your reply.
    Thank you.
    ATR

  • TS3212 I'm runing IE9 & I'm unable to download iTunes.  I receive this error each time: There is a problem with this windows installer package.  A program required for the program to complete could not be found.  Contact your support personnel or package

    I'm running IE 9 & windows 7.  I'm unable to download iTunes.  I receive this error each time: There is a problem with this windows installer package.  A program required for the program to complete could not be found.  Contact your support personnel or package vendor.

    There is a problem with this windows installer package.  A program required for the program to complete could not be found.  Contact your support personnel or package vendor.
    Let's try the following user tip with that one:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • I have an account in Adobe, but every time I work out on any product from Adobe products The program tells me I Trail You remove and re-install the program, but problem persists

    I have an account in Adobe, but every time I work out on any product from Adobe products
    The program tells me I Trail You remove and re-install the program, but problem persists

    Hi mahmod alsousi,
    Try this:
    Sign out from the Creative Cloud app and Quit it (Quit option will be available after a few seconds).
    Now move the following folders to desktop:
    1) SLCache
    Windows: OS Drive\Program Files (x86)\Common Files\Adobe
    Mac: Library/Application Support/Adobe
    2) SLStore
    Windows: OS drive\ProgramData\Adobe
    Mac: Library/Application Support/Adobe
    3) OOBE
    Windows: OS Drive\Users\<username>\AppData\Local\Adobe
    Mac: /User/Library/Application Support/Adobe
    Now launch Premiere Pro and sign in with your Adobe ID.
    NOTE: Make sure your Anti Virus/Firewall is not blocking any Adobe activation servers. Alternately, you can also check your 'hosts' file for any changes.
    Thanks,
    Rameez

  • XML validation: how to check ALL validation problem for XHTML

    I have a lot of documents in HTML format (not very good) that I would like to convert in XML (XHTML). I know it is not so easy and I would use this strategy in a Java program:
    1. Try to check the well-formness and validation with a XML parser (SAX or Xerces)
    2. If not valid: try to individuate ALL the problems the file has (*and not only the first one that halts the processing process*)
    3. Try to transform the HTML to a validable XHTML with some approach: regular expression or other methods
    So the questions I do to you are the following:
    1. What XML parser do you think is the best for this purposes? SAX or Xerces?
    2. How can I understand what are all the validation problems in the file and not only the first one (If I remember well XML parsers halt the parsing process at the first error...)?
    3. How can I transform the HTML to a valid XHTML? I have only to use RegEx or is there other tools to do this for XHTML and HTML problem?
    Thanks
    r
    Edited by: robertobat on Feb 21, 2009 7:09 PM

    >
    1. Neither of them. (Disregarding the fact that SAX and Xerces aren't in the same category and don't cover all the possibilities.I would say SAX default implementation in JRE and SAX parser in Xerces.
    2. I think you have "valid" and "well-formed" confused. And HTML isn't a dialect of XML so the idea of trying to use an XML parser to handle HTML isn't a good idea.I know very well what is the difference between valid and well-formed but I've used "validation" to represent all the conversion problem. But you are right. I'm convincing myself that using a XML parser as the first step is not a good idea.
    3. Well, this is the real question, isn't it? Those other two were just a waste. Don't screw about with regex, for one thing it doesn't work well for hierarchical structures and for another you won't finish in a finite time. Just use an HTML parser which can produce a DOM, like TagSoup for example. Or run them through HTMLTidy. You could also submit them to one of the internet sites which will validate XHTML for you.I've seen Tidy and its capability to convert an HTML to a XHTML and I think it is better then TagSoup because I have to implement this mechanism in a production environment and I want to use only open source projects that have a very long story and that are strong. But I'll see TagSoup as you say.
    I cannot use an Internet service to convert millions of private documents.

  • Time table for warehousing

    Hi All,
    Where can I find a time table (similar to SH.TIMES) for use
    in data warehousing?
    The problem with SH.TIMES is that it just have time information
    up to 2001... I4d like something as 10 years from now...
    TIA,
    Marcelo

    Disclosure: I work for NIST, but not in the Computer Security Div. (the group that issues the certificates).
    Looking at the NIST list of validated modules, Lion's crypto module recieved its certification on 3/30/12, but I don't know if this applies to all apps or just the libraries.  It doesn't apply to 3rd party apps yet (note says it will be re-evaluated for that use).  I wouldn't think File Vault is a "third party" app. 
    I'll post more if I find out anything.

  • How many times a program has been run?

    Is there a transaction or table or something that tracks how many times a program has been run?   The number of times the program has been run plus using the programs' attributes for last changed would help me a lot.  We need this for an archiving study to determine of the client has set up the configuration correctly since they went live and have been executing the correct programs.  Thanks and mucho rewards if someone has an answer.  FYI - I have done a forum search and could find nothing on this topic.  I have looked at the tables TADIR and no help, as well as transaction STAT.

    I know ST03N transaction can be used extensively to determine how the programs were executed or even to know who all are using a particular transaction...
    I tried to find if we can find the number of executions of a program through this transaction, I could not find myself...
    try if you can find it through this tcode.
    Phani

  • Please help me with the digital signature validation problem?

    Please help me with the digital signature validation problem?

    Hi
    Execute the program in the Debuggin mode.
    In the Debugger Window
    Select Breakpoint -> Break point at -> Breakpoint at source code Menu Item and enter the details of the program/include/line no..
    Activate the System Debugger On from the Settings Menu.
    Hope this would help you.
    Murthy
    Edited by: Kalyanam Seetha Rama Murthy on Jul 18, 2008 7:20 AM

  • TS1702 I had this Scrabble on my iPad2 and began to have connection problems, it would lock in the "connecting" position. This is not the first time Scrabble has had problems with interface. Typically customers delete the Ap then download it again to rein

    I have contacted EA about this and can find no help. I had this Scrabble on my iPad2 and began to have connection problems, it would lock in the "connecting" position. This is not the first time Scrabble has had problems with interface. Typically customers delete the Ap then download it again to reinstall it. During the process you sign in and approve the purchase KNOWING that another window will open saying that you have previously purchased it and that there is no charge. So what happened this time? It will not connect and all of my saved and current games are wiped out. I want my money back, this game interface is pretty junk and operates like some ancient DOS program,,bug,bug,buggy. I want my money back.

    Go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • Validation problem in Mapping

    Hi,
    I am getting this error when I am trying to validate the mapping
    Source table is QMI
    " VLD-1002: Mapping object QMI is not bound to a repository object.
    All objects in a mapping must be bound to objects in the Design Repository. Unbound objects inherit the logical location of the module that owns the mapping. Warehouse Builder cannot generate the physical access specification (schema name and database link) for this unbound object. Perform a synchronization from QMI. "
    Could, some body give me a solution for this validation problem.
    Cheers,
    Krishna,

    Hi,
    Thanks for your suggestions. I followed your steps and validating didnt returns any errors.
    But, When I am trying to deploy I am getting a message
    DEPLOYMENT STATUS : USE DEPLOYMENT
    UNDO OR REDO BUTTONS TO CLOSE
    WINDOW TO FINISH, PROCESSED : 0, ERRORS :0, WARNINGS :0.
    I am able to deploy the mappings but not the source tables and target tables. I am getting deploy status failed in the control cetner.
    The work process of my scenario is as follows:
    1) I am having two tables from which I need to populate my target ( NEW table ) with some of the columns from those tables.
    2) I created a two stage tables manually in the database for both of the source tables in two different mappings
    source table 1 into stage table 1 in mapping 1
    source table 2 into stage table 2 in mapping 2
    3) I created a third table as the final target table where I can map these two stage tables into that .
    stage table 1 and stage table 2 into target table in mapping 3 using a JOINER operator. I had given the join condidion as well.
    4) All these stage tables and the final target table and the mappings are in the target module.
    Is this is the way to work on these type of scenarios. Actually I need to JOIN 8 tables and pull some of the necessary columns into the target table based on the condition.
    Intitially I had used a JOINER condition to JOIN those 8 tables in a single mapping.But it gave me the deployment error.
    Could you guys please give me a hand by giving me some suggestion how to proceed in this scenario.
    Last question : Are there any training centers in chennai or Hyderabad where I can get some trining over OWB 10g.
    Cheers,
    Krishna.

  • Xml schema validation problem

    Hi All
    How to tackle this xml schema validation problem
    i am using the sample code provided by ORacle technet for xml
    schema validation in the Oracle database(817).
    The sample code works perfectly fine.
    Sample as provided by http://otn.oracle.com/tech/xml/xdk_sample/archive/xdksample_093001.zip.
    It works fine for normal xml files validated against
    xml schema (xsd)
    but in this case my validation is failing . Can you let me know why
    I have this main schema
    Comany.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.company.org"
    xmlns="http://www.company.org"
    elementFormDefault="qualified">
    <xsd:include schemaLocation="Person.xsd"/>
    <xsd:include schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Person" type="PersonType" maxOccurs="unbounded"/>
    <xsd:element name="Product" type="ProductType" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    ================
    which includes the following 2 schemas
    Product.xsd
    ============
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="Type" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    ==============
    Person.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="PersonType">
    <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="SSN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    =================
    now when i try to validate a xml file against Company.xsd
    it throws an error saying unable to find Person.xsd.
    no protocol error
    Now where do i place these 2 schemas(.xsd files) Person & product
    so that the java schemavalidation program running inside Oracle
    database can locate these files
    Rgrds
    Sushant

    Hi Jinyu
    This is the java code loaded in the database using loadjava called by a wrapper oracle stored procedure
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import java.net.*;
    import java.io.*;
    import org.w3c.dom.*;
    import java.util.*;
    import oracle.sql.CHAR;
    import java.sql.SQLException;
    public class SchemaUtil
    public static String validation(CHAR xml, CHAR xsd)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    byte [] docbytes = xsd.getBytes();
    ByteArrayInputStream in = new ByteArrayInputStream(docbytes);
    XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
    //Parse the input XML document with Schema Validation
    docbytes = xml.getBytes();
    in = new ByteArrayInputStream(docbytes);
    DOMParser dp = new DOMParser();
    // Set Schema Object for Validation
    dp.setXMLSchema(schemadoc);
    dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    dp.setPreserveWhitespace (true);
    StringWriter sw = new StringWriter();
    dp.setErrorStream (new PrintWriter(sw));
    try
    dp.parse (in);
    sw.write("The input XML parsed without errors.\n");
    catch (XMLParseException pe)
    sw.write("Parser Exception: " + pe.getMessage());
    catch (Exception e)
    sw.write("NonParserException: " + e.getMessage());
    return sw.toString();
    This is the code i used initially for validating a xml file against single xml schema (.xsd) file
    In the above code could u tell how to specify the second schema validation code for the incoming xml.
    say i create another Schemadoc for the 2nd xml schema.
    something like this with another parameter(CHAR xsd1) passing to the method
    byte [] docbytes1 = xsd1.getBytes();
    ByteArrayInputStream in1 = new ByteArrayInputStream(docbytes1);
    XMLSchema schemadoc1 = (XMLSchema)builder.build(in1,null);
    DOMParser dp = new DOMParser();
    How to set for the 2nd xml schema validation in the above code or can i combine 2 xml schemas.
    How to go about it
    Rgrds
    Sushant

  • Dynamic region table with binding problem

    Hi. I'm using jdev 11.1.1.3 and ADF full stack.
    My app uses single page approach with ADF libraries and a dynamic region to show content. Main page includes a menu bar which is created on session startup and is used to load task flows from libraries.
    I have a class to provide some table functionality like CRUD, multi-row delete, etc and I need to reuse with every table included in libraries.
    To do this, in main web app I have a managed bean to hold table binding and to provide this common functions to all fragments if needed.
    I think it must be in request scope as fragment changes.
    Here's the problem: when I navigate to a fragment which contains a table with binding, first time goes well,
    but next time table, when fragment changes,new table displays without header or without data.
    If I go to another fragment without binding and return to a fragment with problem, it displays well. With fragments without table binding, it works OK.
    I've tried changing scope of this 'general' managed bean, but same thing. If I put a bean for each fragment, it works OK.
    So, how can I 'share' this managed bean through every table? Any suggestions? is it possible?
    Please, help me ....
    Thanks,
    DEMR.

    I am seeing a similar problem in my app. I have a main menu that drives a dynamic region. If the task flow that gets displayed in the dynamic region also contains a dynamic region, when the inner dynamic region is refreshed to point to a second task flow, the page does not render correctly. The errors we have seen include data in tables not being displayed in some cases, and PPR errors in other cases. In both cases, if the inner dynamic region is replaced (by a single bounded task flow with navigation logic in a template, for example) the errors go away. There appears to be issues involved with including a dynamic region within a dynamic region.
    Have you made any progress on solving your issue?

  • When was the last time a program was run?

    Experts, is there a way to know when was the last time a program was run (particularly, Z Program). We are trying to identify obsolete programs and avoid working on those programs that weren't touched for more than 3 years during our next upgrade. How can I find this? Any suggestion would be highly appreciated.
    Thank you.

    Hi,
    One way is to check TRDIR table(se11/se16) and display it. In the next screen once you will get 'Data Browser Table TRDIR' selection screen. There either you put the individual 'Z' program name in the 'Name' field & execute it or for all multiple entries execute it.
    Once you execute it with the particular Z prog. name then you will get the required details like CDAT(Created on),UNAM(Last changed by),UDAT(Changed On),SDATE(Standard selection screen generation: Date),IDATE(Selection screen generation: Date) etc.
    Hope this can help you.

Maybe you are looking for

  • How to use one SessionInfo for many Frame

    Hi Sathish; thank's for your answer but How do this? thank you

  • Relationship BCS-Profit Centre and FAGLFLEXT

    Hi, I'm in ECC5, using BCS 4.0 and BW 3.5. Our current designed required 2 type consolidation, which is company consolidation and profit centre consolidation. Note that the profit centre consolidation also required balance sheet and profit/loss. Now,

  • Change Customer on existing Contract

    Hi Guys Brief question Does any1 know a way to change the customer on a contract that already has follow up documents as invoices etc. While the payer is open the customer in our case it is already greyed out. I guess it is not recommended as invoice

  • Mountain Lion Safari doesn't allow Yahoo Mail address suggesting

    Yahoo Mail suggests addresses as they're typed into the To: field, drawing from the list built in Yahoo Mail. I know this feature works with Internet Explorer in Windows, with Safari in Snow Leopard, and with Firefox in Mountain Lion. But it doesn't

  • Reinstall or edit broken search engine setting

    The Creative Commons Beta search engine addon seems to be broken for me in Firefox, taking me to a 404 page each time. If I try reinstalling it from the Creative Commons site I get a popup message: "Firefox could not install the search plugin from "h