Very New To Java

Hi, I'm very new to java - 2nd day. Trying to move from Visual FoxPro.
In testing statements to learn java, I can't seem to get java.util.Scanner.nextInt or nextDouble ... etc. to wait for a keyborad input. Is there something I have to configure before utilizing ...Scanner.nextWhatever?
I'm using the latest java (just downloaded 2 day ago) and TextPad as my editor.
Thanks you.

Hi Petes1234:
Thanks for you quick response!!!!
The following is the code very simple ... still my "Hello World!" phase of learning.
import java.util.Scanner;
public class ScannerApp
     static Scanner sc = new Scanner(System.in);
     public static void main(String[] args)
          System.out.print("Enter an integer: ");
          int x = sc.nextInt();
          System.out.println("You entered " + x + ".");
}The above code complies fine. But when I try to run it, it errors out with the following error:
Enter an integer: Exception in thread "main" java.util.NoSuchElementException
     at java.util.Scanner.throwFor(Scanner.java:838)
     at java.util.Scanner.next(Scanner.java:1461)
     at java.util.Scanner.nextInt(Scanner.java:2091)
     at java.util.Scanner.nextInt(Scanner.java:2050)
     at ScannerApp.main(ScannerApp.java:11)
See anyting I'm doing wrong here?

Similar Messages

  • Very New to Jave, need to do totals/subtotals

    Hi, (I hope this is the right place)
    I'm VERY new to Java (I mainly do wourk with php interfaces for MyAQL databases).
    Up until now, there hasn't been anything I couldn't do with PHP that I needed to...
    My boss recently requested subtotals/totals at various points on an input sheet. The sheet inputs numbers of people, so I'm not worried about rounding (The php already takes care of people trying to input parts of people....) or tax.
    It's a rather large form (~144 lines) and the math is already in place to do the subtotaling (among other things) before entering the information into the database.
    How would I go about writing script that would display sub totals, and recalculate them every time one of the boxes value's is modified?
    Is this something javascript is designed to do? Is there a better language out there for this task?
    I've found sites out there that have canned subtotal/total scripts, but I don't want something pre-made unless it comes with a detailed explaination of what everything does; if I'm going to maintain it, I have to understand it.
    Thanks

    Is this a web form? e.g. a html form with input fields?
    You can add onchange or onblur events to your input fields to detect changes. Then you can use javascript to retrieve the values from the form and do the calculation.
    -S

  • Very new to java please help

    i'm very new to java and i'm getting an error in my application. i took 4 applications that compiled and worked separatly and i tried to combine them into one application. i'm getting the error: unreported exception java.io.IOException; must be caught or declared to be thrown, in lines 73,78,83,88,120,146,149,152,155 in the and it points at the keyboard.readLine() but everything i've tried just gives me more errors. please help anything and everything will be greatly appreciated. here it is, sorry about format i dunno how to straighten it in here:
    // ^ ^
    //               (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
         static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
         static PrintWriter screen = new PrintWriter(System.out, true);
         public static void main (String[] args) throws IOException
              double hoursa, minutesa, secondsa;
              String hours;
              System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
              System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // An application that finds the distance between two points when the points
    // are given by the user.
              double x1, x2, y1, y2, total, distance;
              String xa;
              System.out.print ("Please enter the 'x' coordinate of first point: ");
              xa = keyboard.readLine();
              x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
              String ya;
              System.out.print ("...also need the 'y' coordinate of first point: ");
              ya = keyboard.readLine();
              y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
              String xb;
              System.out.print ("...and the 'x' coordinate of the second point: ");
              xb = keyboard.readLine();
              x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
              String yb;
              System.out.print ("...don't forget the 'y' coordinate of the second point: ");
              yb = keyboard.readLine();
              y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
              total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
              distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
              System.out.print ("E=mc^2...oh and,");
              System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
              xb + "," + yb + ") is : " + distance);
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
              double radius,volume,area;
              String rad;
              System.out.print("Please enter the radius of a sphere: ");
              rad = keyboard.readLine();
              radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
              volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
              System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
              area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
              System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
              int pennies, nickels, dimes, quarters;
              double money1;
              screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
              int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
              screen.println("How many dimes?: ");
              int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
              screen.println("How many nickels?: ");
              int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
              screen.println("How many pennies?: ");
              int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
              NumberFormat money = NumberFormat.getCurrencyInstance();
              money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
              screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money

    Ok here is the working code as one long function:
    // ^ ^
    // (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
        static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter screen = new PrintWriter(System.out, true);
        public static void main (String[] args) throws IOException
    double hoursa, minutesa, secondsa;
    String hours;
    System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
    System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // }  <----- MAIN FUNCTION USED TO END HERE!!!
    //but we want to keep going so remove the bracket!
    // An application that finds the distance between two points when the points
    // are given by the user.
    // {  <-- other function used to start here, but now it continues
    double x1, x2, y1, y2, total, distance;
    String xa;
    System.out.print ("Please enter the 'x' coordinate of first point: ");
    xa = keyboard.readLine();
    x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
    String ya;
    System.out.print ("...also need the 'y' coordinate of first point: ");
    ya = keyboard.readLine();
    y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
    String xb;
    System.out.print ("...and the 'x' coordinate of the second point: ");
    xb = keyboard.readLine();
    x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
    String yb;
    System.out.print ("...don't forget the 'y' coordinate of the second point: ");
    yb = keyboard.readLine();
    y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
    total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
    distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
    System.out.print ("E=mc^2...oh and,");
    System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
         xb + "," + yb + ") is : " + distance);
    //second function used to end here...
    //} <--- COMMENT OUT BRACKET SO WE CONTINUE
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
    //{ <--- ANOTHER ONE TO COMMENT OUT
    double radius,volume,area;
    String rad;
    System.out.print("Please enter the radius of a sphere: ");
    rad = keyboard.readLine();
    radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
    volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
    System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
    area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
    System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // } <----- COMMENTED OUT FOR THE SAME REASON
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
    //{ <----AND ANOTHER
    int pennies, nickels, dimes, quarters;
    double money1;
    screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
    int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
    screen.println("How many dimes?: ");
    int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
    screen.println("How many nickels?: ");
    int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
    screen.println("How many pennies?: ");
    int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
    NumberFormat money = NumberFormat.getCurrencyInstance();
    money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
    screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money
    }P.S. To make the code formatted better put [ code ] before and [ /code ] after. It's not perfect, but a little better...

  • Very new to Java!!! HELP!!!!

    very simple, how do I set everything up in Windows XP????
    it doesn't seem to work for me!
    I tried to run javac.exe and java.exe it just goes to command prompt and then disappears!!!!!!! AHHHHHHHHHH!!! help!
    thanks

    i get the error when I run the helloworldapp
    this: C:\documents and settings\hanamachi\java stuff>
    java HelloWorldApp
    Exception in thread "main"
    java.lang.NoClassDefFoundError: HelloWorldApp
    huh???You didn't follow the directions carefully, particularly the part about setting your classpath. You can remedy this in the short term by using the following command:
    java -cp . HelloWorldAppI highly recommend you go back through the instructions, though, and follow them very carefully.

  • Writting Tools for Java (Very new to java HELP!!!!)

    It's hard to write a java applet using a windows notepad, because I must to save as a *.java files, open a msdos prompt type (javac *.java), and run it (very inefficinet :( ).
    Doesn't like Vb, notepad didn't alert me if I make a mistake like this :.
    --System.out.println("good")
    --Sistem.out.println(":( wrong)
    HELP ME PLEASEEEEE!!!!

    Forte, where can I download it from?Link to Forte (now called Sun One Studio 4):
    http://wwws.sun.com/software/sundev/jde/index.html
    Link to JCreator (a text editor):
    http://www.jcreator.com/
    Link to search results on Google.com:
    http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=java+ide%2Ceditor

  • Very new at Java

    Hello,
    I have am new also to Java and would like to know what to download first. I want to work with databases and use java as the front end. The databases I use are MySql. I am really excited about this language because I have a Apple at home and a PC at work. By the way I have read this I can use both and not have to worry about different OS. This sounds great.

    Hi
    Welcome to Java!
    I don't know much about Macs, but for PC you need the following:
    -The JDK (Java Development Kit)
    JDK 5 is the current version (jdk 6 due before end of year).
    http://java.sun.com/javase/downloads/index.jsp
    -A Java IDE (Integrated Development Environment - in case you didn't know ;) )
    I recommend Netbeans as your IDE. Check out:
    www.netbeans.org
    It's free and runs on Mac too, assuming you have jdk5.0 for Mac. Netbeans 5.5 is the latest version (released a few days ago) and requires jdk5.0, Netbeans 5.0 requires only JDK1.4.2 if you only have on older JDK on your mac. Various plugins are available on the netbeans site too.

  • Very new in Java pls help!!!!!!

    hello,
    i just started to learn java and trying to do my first program, but dont know why i cant do that! it asking me to set my PATH in sdk bin folder with jdk and i dont know how to do that, couse i install it in diferent folders! im trying to set c:\jdk1.6\bin;%PATH% but writing "environment variable c:jdk1.6\bin;C:\windows\system32;C:\windows;C:\windowasystem32\wbem;C;\program files\cyberlink\power2Go\C:\sun\SDK\bin not defined" help me please!!!

    - Right click 'my computer', select 'properties'.
    - Click the 'advanced' tab.
    - click the 'environmental variables' button
    Here you will find the PATH environmental variable, most likely under system variables. Add the path to the JDK bin directory here.
    Note: If you have a command prompt open while you are doing this, open a new one as the old one will not see the changes you make. To make sure the PATH is valid, open a command prompt and type:
    echo %PATH%

  • Very new in Java

    I go start my course in Java programming,but first, because i need start from the beggining i need make one module wich gonna take me around 1 nad a half month. Because i want star more soon understand about programming i bought "Java A beginner's guide. Note i never make any kind of programming in my life. I start read the book and not found any problem my problem appears when i reach the first simple program. I get the J2SE 5 and they say the program run in command prompt but my command prompt when i open always appears c:\>documents and settings>nuno blanc i just ca,t take out that .documents and settings. i try everything what i know.
    They say is well for i use Word Pad. i use the word pad and after i dont know how to run the program witch i made. If someone able to help-me please help me here or in my mail [email protected] i want start enter in programming.
    Please!
    Thank's

    I go start my course in Java programming,but first,
    because i need start from the beggining i need make
    one module wich gonna take me around 1 nad a half
    month. Because i want star more soon understand about
    programming i bought "Java A beginner's guide. Note i
    never make any kind of programming in my life. I
    start read the book and not found any problem my
    problem appears when i reach the first simple
    program. I get the J2SE 5 and they say the program
    run in command prompt but my command prompt when i
    open always appears c:\>documents and settings>nuno
    blanc i just ca,t take out that .documents and
    settings. i try everything what i know.
    They say is well for i use Word Pad. i use the word
    pad and after i dont know how to run the program
    witch i made. If someone able to help-me please help
    me here or in my mail [email protected] i want start
    enter in programming.
    Please!
    Thank'sHi,
    Unfortunately, it's fairly difficult to get Java set up on your computer and learn to run programs. You should read the tutorial, "Your first Cup of Java":
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/
    It will lead you through the steps of installing Java and running your first program.
    Because i want star more soon understand about
    programming i bought "Java A beginner's guide. I've read the 2nd edition of that book, and I thought it was a good book. I do have previous programming experience, though. I thought it was a good, short overview of Java. Other beginning books are much longer and can get pretty complicated.
    Good luck.

  • Very New To Java, Using Sun One Studio

    I am doing a small work project for a company and they would like me to do a small project using the JavaMail API and the Java One Studio.
    Now I have some experience with Java, It is installing the JavaBeansTM Activation Framework and the JavaMail API to my Classpath.
    How do I figure out what my class path is?
    Thanks Mike

    If on windows or unix, in a shell, type set.
    If on mac OS, then I don't know. Sorry.

  • Very new to Java, trying to make a jar file run on WM6

    Ok so i downloaded this java progam that is supposed to work on "java-enabled" phones. So i have windows mobile 6, which is able to run java but i think its limited to the browser. when i try to run it on a virtual java machine i recieve the following error.
    java.lang.Exception: No Main-Class attribute in \My Documents\TrafficPilot.jar
    at java.lang.VMMainThread$1.run(VMMainThread.java)
    at java.lang.VMThread.run(VMThread.java:120)
    JVM exit
    what is needed to make this work? or is it even possible?

    Hi, welcome to the Sun Java forums.
    Pester the person who gave you the JAR, s/he did something wrong.
    Pass this information on to them:
    Add a MANIFEST.MF file in the JAR's META-INF directory (all names case-sensitive) and put this line in it, with two Enters after it:
    Main-Class: mypackage.MainClassName
    Though if the JAR contains an applet (which would explain why it only works in a browser), it might not have a main class.

  • PLZ help me out i'm very new and confused to java

    Hi~
    I'm very new to java and I just brought a phone (Nokia 6670). It's capable of J2ME, as it says in the instrusction book, but I'm not so sure which Java to download. (THERE ARE SO MANY). Please help me out, I'm not sure what to do, since I'm putting games in Java.

    you want to develop your own game or just want to have some games on your new device?
    your phone has java runtime already, and that's all you need to run java games .. you can download them from several locations
    if you want to develop your own game then download Sun's J2ME Wireless Toolkit; also have a look at Nokia Developer's Suite and emulator for your device...

  • Convert C++ prog into Java( I m new in java)help urgent

    hi all,
    i am very new in java. i have code of C++.i have to convert it in to Java.please help me on urgent basis.plz provide me solution.
    I am looking for positive response.code is below:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sys/stat.h>
    #include <fstream.h>
    #include <iostream.h>
    //#include <sha.h> //24112003
    //#include<wincrypt.h>
    char ntc(unsigned char n){
    if (n<26) return 'A'+n;
    if (n<52) return 'a'-26+n;
    if (n<62) return '0'-52+n;
    if (n==62) return '+';
    if (n==63)return '/';
    unsigned char ctn(char c){
    if (c=='/') return 63;
    if (c=='+') return 62;
    if ((c>='A')&&(c<='Z')) return c-'A';
    if ((c>='a')&&(c<='z')) return c-'a'+26;
    if ((c>='0')&&(c<='9')) return c-'0'+52;
    if (c=='~') return 80;
    return 100;
    int b64decode(char from,char to,int length){
    unsigned char c,d,e,f;
    char A,B,C;
    int i;
    int add;
    char *tot=to;
    for (i=0;i+3<length;){
    add=0;
    A=B=C=0;
    c=d=e=f=100;
    while ((c==100)&&(i<length)) c=ctn(from[i++]);
    while ((d==100)&&(i<length)) d=ctn(from[i++]);
    while ((e==100)&&(i<length)) e=ctn(from[i++]);
    while ((f==100)&&(i<length)) f=ctn(from[i++]);
    //if (f==100) return -1; /* Not valid end */
    if (c<64) {
    A+=c*4;
    if (d<64) {
    A+=d/16;
    B+=d*16;
    if (e<64) {
    B+=e/4;
    C+=e*64;
    if (f<64) {
    C+=f;
    to[2]=C;
    add+=1;
    to[1]=B;
    add+=1;
    to[0]=A;
    add+=1;
    to+=add;
    if (f==80) return to-tot; /* end because '=' encountered */
    return to-tot;
    int b64get_encode_buffer_size(int l,int q){
    int ret;
    ret = (l/3)*4;
    if (l%3!=0) ret +=4;
    if (q!=0){
    ret += (ret/(q*4));
    /* if (ret%(q/4)!=0) ret ++; */ /* Add space for trailing \n */
    return ret;
    int b64strip_encoded_buffer(char *buf,int length){
    int i;
    int ret=0;
    for (i=0;i<length;i++) if (ctn(buf)!=100) buf[ret++] = buf [i];
    return ret;
    int b64encode(char from,char to,int length,int quads){
    // 3 8bit numbers become four characters
    int i =0;
    char *tot=to;
    int qc=0; // Quadcount
    unsigned char c;
    unsigned char d;
    while(i<length){
    c=from[i];
    *to++=ntc(c/4);
    c=c*64;
    i++;
    if (i>=length) {
    *to++=ntc(c/4);
    *to++='~';
    *to++='~';
    break;
    d=from[i];
    *to++=ntc(c/4+d/16);
    d=d*16;
    i++;
    if (i>=length) {
    *to++=ntc(d/4);
    *to++='~';
    break;
    c=from[i];
    *to++=ntc(d/4+c/64);
    c=c*4;
    i++;
    *to++=ntc(c/4);
    qc++; /* qz will never be zero, quads = 0 means no linebreaks */
    if (qc==quads){
    *to++='\n';
    qc=0;
    /* if ((quads!=0)&&(qc!=0)) to++='\n'; / /* Insert last linebreak */
    return to-tot;
    char* mEncryptPassword(char* mPassword)
    char mEncryptedPassword[200]; // To hold encrypted password.
    //char* mEncryptedPassword = new char[200];
    char mPrimEncryptedPassword[200];
    char * temp = new char[200];
    //unsigned char* md; // 19122003
    //md = new unsigned char[100]; // 19122003
    memset(mEncryptedPassword, '\0', sizeof(mEncryptedPassword));
    memset(mPrimEncryptedPassword, '\0', sizeof(mPrimEncryptedPassword));
    strcpy(mPrimEncryptedPassword, mPassword);
    //strcpy(mPrimEncryptedPassword, (char*) SHA1((unsigned char*) mPassword, strlen(mPassword), NULL));
    //strcpy(mEncryptedPassword, (char*) SHA((unsigned char*) mPassword, strlen(mPassword), md)); // 19122003
    //strcpy(mEncryptedPassword, (char*) SHA((unsigned char*) mPassword, strlen(mPassword), md)); //19122003
    b64encode(mPrimEncryptedPassword, mEncryptedPassword, strlen(mPrimEncryptedPassword), 0);
    // If successfully encrypts..
    if (mEncryptedPassword != NULL)
    //char * temp = new char[strlen(mEncryptedPassword)+1];
    strcpy(temp,mEncryptedPassword);
    // strcpy(mRetVal,mEncryptedPassword);
    return (char*)temp;
    //return (mEncryptedPassword);
    //return (char*) md; // 19122003
    else
    return ("Error");
    char* mDecryptPassword(char* mPassword)
    char mDecryptedPassword[200]; // To hold decrypted password.
    char mPrimDecryptedPassword[200];
    char * temp = new char[200];
    // 02032007
    memset(mDecryptedPassword, '\0', sizeof(mDecryptedPassword));
    memset(mPrimDecryptedPassword, '\0', 200);
    strcpy(mPrimDecryptedPassword, mPassword);
    b64decode(mPrimDecryptedPassword, mDecryptedPassword, strlen(mPrimDecryptedPassword));
    // If successfully decrypts..
    if (mDecryptedPassword != NULL)
    //char * temp = new char[strlen(mEncryptedPassword)+1];
    strcpy(temp,mDecryptedPassword);
    // strcpy(mRetVal,mDecryptedPassword);
    return (char*)temp;
    //return (mEncryptedPassword);
    //return (char*) md; // 19122003
    else
    return ("Error");
    void main(int argc, char* argv[])
    cout << mEncryptPassword(argv[1])<<endl<<flush;
    cout << mDecryptPassword(mEncryptPassword(argv[1]))<<endl<<flush;
    Anubhav

    endasil wrote:
    I just thought of how ridiculous this would sound in any other profession:
    Surgeons:
    plz plz help I have patient dying need to insert new kidney into 90yr old patient plz someone come do itLawyers:
    Help client guilty need good defense (I m new in law)help urgentHow come we get stuck with the lazy low-lifes?Because there's no legal requirement that a software developer must be licensed

  • New TO JAVA Programming

    Dear Forummembers,
    I am student doing postgraduate studies in IT.i have some queries related to one of my programming staff.i am very much new into Java programming and i am finding it a bit difficult to handle this program.The synopsis of the program is given below -
    You are required to design and code an object-oriented java program to process bookings for a theatre perfomance.
    Your program will read from a data file containing specifications of the performance,including the names of the theatre, the play and its author and the layout of the theatre consisting of the number of seats in each row.
    It will then run a menu driven operation to accept theatre bookings or display the current
    status of seating in the theatre.
    The name of the file containing the details of the performance and the theatre should be
    provided at the command line, eg by running the program with the command:
    java Booking Theatre.txt
    where Theare.txt represents an example of the data file.
    A possible data file is:
    Opera
    U and Me
    Jennifer Aniston
    5 10 10 11 12 13 14
    The data provided is as follows
    Line 1
    Name of the Theatre
    Line 2
    Name of the play being performed
    Line 3
    Name of the author of the play being performed
    Line 4
    A list of the lengths (number of seats) of each row in the theatre, from front to
    back.
    The program must start by reading this file, storing all the appropriate parameters and
    establishing an object to accept bookings for this performance with all details for the theatre
    and performance.
    The program should then start a loop in which a menu is presented to the user, eg:
    Select from the following:
    B - Book seats
    T - Display Theatre bookings
    Q - Quit from the program
    Enter your choice:
    And keep performing selected operations until the user�s selects the quit option, when the
    program should terminate.
    T - Display Theatre bookings
    The Display Theatre Bookings option should display a plan of the theatre. Every available
    seat should be displayed containing its identification, while reserved seats should contain an
    Rows in each theatre are indicated by letters starting from �A� at the front. Seats are
    numbered from left to right starting from 1. A typical seat in the theatre might be designated
    D12, representing seat 12 in row D.
    B - Book seats
    The booking of seats is to offer a number of different options.
    First the customer must be asked how many adjacent seats are
    required. Then start a loop offering a further menu of choices:
    Enter one of the following:
    The first seat of a selected series, eg D12
    A preferred row letter, eg F
    A ? to have the first available sequence selected for you
    A # to see a display of all available seats
    A 0 to cancel your attempt to book seats
    Enter your selection:
    1. If the user enters a seat indentifier such B6, The program should attempt to
    reserve the required seats starting from that seat. For example if 4 seats are
    required from B6, seats B6, B7, B8 and B9 should be reserved for the customer,
    with a message confirming the reservation and specifying the seats reserved..
    Before this booking can take place, some testing is required. Firstly, the row
    letter must be a valid row. Then the seat number must be within the seats in the
    row and such that the 4 seats would not go beyond the end of the row. The
    program must then check that none of the required seats is already reserved.
    If the seats are invalid or already reserved, no reservation should be made and the
    booking menu should be repeated to give the customer a further chance to book
    seats.
    If the reservation is successful, return to the main menu.
    2. The user can also simply enter a row letter, eg B.IN this case, the program should
    first check that the letter is a valid row and then offer the user in turn each
    adjacent block of the required size in the specified row and for each ask whether
    the customer wants to take them. Using the partly booked theatre layout above, if
    the customer wanted 2 seats from row B, the customer should be offered first:
    Seats B5 to B6
    then if the customer does not want them:
    Seats B10 to B11
    and finally
    Seats B11 to B12
    If the customer selects a block of seats, then return to the main menu. If none are
    selected, or there is no block of the required size available in the row, then report
    that no further blocks of the required size are available in the row and repeat the
    booking menu.
    3. If the user enters a ? the program should offer the customer every block of seats
    of the required size in the whole theatre. This process should start from the first
    row and proceed back a row at a time. For example, again using the partially
    booked theatre shown above, if the user requested 9 seats, the program should
    offer in turn:
    Seats A1 to A9
    Seats C1 to C9
    Seats C2 to C10
    Seats E3 to E11
    Seats E4 to E12
    If the customer selects a block of seats, then return to the main menu. If none are
    selected, or there is no block of the required size available in the whole theatre,
    then report that no further blocks of the required size are available and repeat the
    booking menu.
    4. If the user enters a # the program should display the current status of the seating
    in the theatre, exactly the same as for the T option from the main menu and then
    repeat the booking menu.
    5. If the user enters a 0 (zero), the program should exit from the booking menu back
    to the main menu. If for example the user wanted 9 seats and no block of 9 was
    left in the theatre, he would need to make two separate smaller bookings.
    The program should perform limited data validation in the booking process. If a single
    character other than 0, ? and # is entered, it should be treated as a row letter and then tested
    for falling within the range of valid rows, eg A to H in the example above. Any invalid row
    letters should be rejected.
    If more than one character is entered, the first character should be tested as a valid row letter,
    and the numeric part should be tested for falling within the given row. You are NOT
    required to test for valid numeric input as this would require the use of Exception handling.
    You are provided with a class file:
    Pad.java
    containing methods that can be used for neat alignment of the seat identifiers in the theatre
    plan.
    File Processing
    The file to be read must be opened within the program and if the named file does not exist, a
    FileNotFoundException will be generated. It is desirable that this Exception be caught and
    a corrected file name should be asked for.
    This is not required for this assignment, as Exception handling has not been covered in this
    Unit. It will be acceptable if the method simply throws IOException in its heading.
    The only checking that is required is to make sure that the user does supply a file on the
    command line, containing details of the performance. This can be tested for by checking the
    length of the parameter array args. The array length should be 1. If not, display an error
    message telling the user the correct way to run the program and then terminate the program
    System.exit(0);
    The file should be closed after reading is completed.
    Program Requirements
    You are expected to create at least three classes in developing a solution to this problem.
    There should be an outer driving class, a class to represent the theatre performance and its
    bookings and a class to represent a single row within the theatre.
    You will also need to use arrays at two levels. You will need an array of Rows in the Theatre
    class.
    Each Row object will need an array of seats to keep track of which seats have been reserved.
    Your outer driving class should be called BookingOffice and should be submitted in a file named BookingOffice.java
    Your second, third and any additional classes, should be submitted in separate files, each
    class in a .java file named with the same name as the class
    I am also very sorry to give such a long description.but i mainly want to know how to approach for this program.
    also how to designate each row about it's column while it is being read from the text file, how to store it, how to denote first row as row A(second row as row B and so on) and WHICH CLASS WILL PERFORM WHICH OPERATIONS.
    pls do give a rough guideline about designing each class and it's reponsibilty.
    thanking u and looking forward for your help,
    sincerely
    RK

    yes i do know that........but can u ppl pls mention
    atleast what classes shud i consider and what will be
    the functions of each class?No, sorry. Maybe somebody else will, but in general, this is not a good question for this forum. It's too broad, and the question you're asking is an overall problem solving approach that you should be familiar with at this point.
    These forums are best suited to more specific questions. "How do I approach this homework?" is not something that most people are willing or able to answer in a forum like this.

  • New to java: how to replace an image extending a JComponent?

    Hi,
    I'm new to Java and I have a question about Swing:
    I have a class called ActiveImage (entends JComponent, implements     MouseMotionListener, MouseWheelListener) which takes an Image and displays it. It also receives some mouse events for zooming and moving it around. I display it in a JFrame using:
    content = getContentPane();
    content.setLayout(new BorderLayout());
    image = toolkit.getImage (filename);
    ActiveImage activeImage = new ActiveImage(image);
    content.add(activeImage, BorderLayout.CENTER);
    (This code is in a class extending JFrame.)
    This works fine. However, this JFrame also contains a JToolbar with two buttons. Now when I click one of them, I want to replace the image with another one. I've tried removing it and creating a new ActiveImage to add that to content, but that didn't work very well. remove() resulted in a NullPointerException.
    My question: what would be the best way to go about this?
    Many thanks for any help,
    Diederick de Vries

    B.T.W., this is the trace:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at ActiveImage.ActiveImageFrame$1.actionPerformed(ActiveImageFrame.java:60)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
            at java.awt.Component.processMouseEvent(Component.java:5488)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
            at java.awt.Component.processEvent(Component.java:5253)
            at java.awt.Container.processEvent(Container.java:1966)
            at java.awt.Component.dispatchEventImpl(Component.java:3955)
            at java.awt.Container.dispatchEventImpl(Container.java:2024)
            at java.awt.Component.dispatchEvent(Component.java:3803)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
            at java.awt.Container.dispatchEventImpl(Container.java:2010)
            at java.awt.Window.dispatchEventImpl(Window.java:1766)
            at java.awt.Component.dispatchEvent(Component.java:3803)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)Just before this, it says "button clicked". The function that calls the setImage() goes:
    theButton.addActionListener (new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
              System.out.println("button clicked");
              activeImage.setImage(image);
    });Reading the trace, I would think that the exception has something to do with this last code, since it stops there (line 60 is the setImage()). If the setImage() function itself was where the fault was, wouldn't the trace end there?
    I'm really at a loss here ... :-(

  • Issue with new EWS Java 1.2 license and ambiguity

    If this isn't the proper place for this thread, then please let me know where it should go.
    I noticed that EWS Java 1.2 has been marked with an Apache 2.0 license. Let me just say this...
    FINALLY!
    If ever there was a project that needed it, it's EWS Java. That API has seemingly turned into abandonware and the old license forbade redistribution of modified source, so the many bugs in it had to be independently fixed by devs around the world. Not fun.
    With a proper open source license, this problem can be alleviated.
    HOWEVER...
    After downloading the zip file from the new EWS Java page, I've found that while the Apache 2.0 license is present in the root directory, the earlier and more restrictive license is still present in the project directory. This introduces ambiguity into the
    license terms. Not good. I would not be comfortable redistributing modified (or even original) source code with this kind of ambiguity, even if it's just an oversight on Microsoft's part. Please remove the old license entirely from the API.
    Also, if possible, can this get an official repository? The new license is great, but with only a zip file as an "official" source, it's begging for fragmentation across who-knows-how-many repositories and accounts, especially since it's not even
    a proper Maven project.
    I'd love to do some work on EWS Java myself (I've already fixed a number of bugs), but with the license issues and lack of an official repository, that doesn't seem terribly feasible.

    I'm not sure if you're going to be able to reliably find an actual fulltime MSFT person (especially targeted towards a specific product group) in any of these forums. You might try posting a comment on this blog post though, that might help get someone's
    attention:
    http://blogs.msdn.com/b/exchangedev/archive/2013/01/03/ews-java-api-1-2-get-started.aspx?Redirected=true#comments
    We do have a Microsoft employee who moderates this forum, but since this forum is only meant for feedback on the defunct TechNet subscriptions I don't think he'll be able to help you out very much. We'll see though, maybe Mike has some Exchange team connections
    that I don't know about.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

Maybe you are looking for