If you are having a problem getting your code to compile correctly with online gdb, you should use the Scanner class instead of the JOptionPane class. Although a little different, it is easier than the dialog boxes and you don't have to parse the Strings to ints or doubles. Below is a simple program that shows you how to use the Scanner class to input data to your program. I will also include a word doc file attachment below the scribd doc. If you are still having problems when using the scanner class, email me.
Welcome back everybody.
The last two weeks were officially our "snow days" and adjusted "Spring break" days due to the corona virus with no work being mandatory from the students. Going forward, your assignments will be updated on this site on a regular basis. If you haven't already done so, please read the last several posts for important information. I have also sent an email to every parent/guardian email listed on Eschool. If no email was received from my school email at [email protected], please have them email me with a working email address and I will make sure I update them to my distribution lists. (It is possible that an email was received, but it was automatically forwarded to the spam folder.) For this next week, we will do some programs reviewing the basics and making sure that you have a compiler and development environment in which you can write, compile and execute a java program if you haven't already done so. (See the prior posts for information on this.) Your first assignment that is due Wednesday 4/1/20 is as follows: You are to write a program with methods called findSquare( ) and findCube( ), in addition to the main method. The program will prompt the user for a number in the main method. The main will parse the input as a decimal and then pass the values to the two methods. findSquare( ) - will find the square of the number entered and print the value out in the method itself. findCube( ) - will find the cube of the number entered and return the value to the main where the answer will be printed out. The main should then ask if you want to find the values for another number, quitting when the user indicates that they are done. Assignment 2 is due Monday, 4/6/20. The program will request the user to enter some text (a sentence or two). Using the methods from the String class, the program will determine how many words are in the text. Hint - each word is always separated by a space. As a reminder, the API documentation for the version we use can be found at: https://docs.oracle.com/javase/8/docs/api/ When you are done with your source code, just copy and paste the text of it in the body of an email and send it to me at [email protected]. Don't email an actual file. If you have any questions, email me. There will be a quiz or test some time within the next two weeks. Stay Healthy!!!! I have sent an email update to all parents of my students based on the email information listed in the Eschool portal.
If you have not received an email from me today, 3/28/2020 please send me an email at [email protected]. I hope everybody is healthy and doing well. For this next week, I would like everybody to choose a preferred development environment in which to write code. You may use the online compiler at: https://www.onlinegdb.com/online_java_compiler from the website www.onlinegdb.com. This was the site we used at the beginning of the year for the C++ coding that we did. This site will be sufficient for most of the basic projects that are normally done in the intro class. For those who wish to work on their own with more advanced concepts, and especially for those planning on taking the AP computer science course next year, I recommend downloading the JDK - java development kit standard edition and an interactive development environment of your choice. I am including instructions below that give the links and instructions for downloading 1)the JDK, 2) API Documentation and 3) a development environment called Eclipse in which you can write your code. It is not the same as we use in class, but it is more up to date and works very well. It also has a very good tutorial explaining the ins and outs of learning to use the Eclipse IDE. For this next week, either practice writing some of your old programs using either onlinegdb or the Eclipse IDE, and getting them to compile and execute correctly. Next week, we will start some new projects. Again, the instructions to find and download the JDK and Eclipse IDE are below. Stay safe and stay healthy!!! Mr. K. The String class.
Basic methods, usage, reading the code from the documentation. Practice with basics. Handout - simple practice with String class methods. Finishing up with basic methods
- Triangle program using methods - Geometry program using methods. Extra help Tuesday room A208 |
Archives
May 2020
Categories |