My goal is to make a working spell check program.I have made some progress, but the more I test, the more issues I get and I continue to edit the algorithm.
import java.util.*;
import java.io.*;
public class SpellCheckTestClass{
public static void main(String [] args) throws IOException{
ArrayList<String> englishwords = new ArrayList<String>();
ArrayList<String> suggestions = new ArrayList<String>();
Scanner in = new Scanner(System.in);
String entry = in.next();
I created my own class and it basically randomizes the amount of 'spells' [magic] a user uses (range 1-5). I can't figure out how to increment the initial randomized output to make something like this :
User X : uses 2 spell. User Y : uses 3 spells.
User X : uses 3 spells. (Taking the randomized 2 and increment by 1) User Y : uses 4 spells. (Taking the randomized 3 and increment by 1)
My current setup looks like this : First one is the class I created and the second one is just how the output would look like. (seperate by +++++...)
My goal is to create a METHOD to increment it.
public class Spell { // Max number of spells private final int MAX_FACE_VALUE = 5; // Current face value private int faceValue; // New instance of Spell public Spell() { faceValue = 1;
[Code] ....
+++++++++++++++++++++++++++++++++
public class SpellOutput { public static void main(String[] args) { //Object creation Spell spellCasterOne = new Spell(); Spell spellCasterTwo = new Spell(); Spell spellCasterThree = new Spell();
I have to ask how many children's tickets you want to order. When I apply the code below, it just accepts whatever I input, including letters. I imagine it is to do with setting childrensTickets = 0? If I input a letter using the below it accepts - shouldn't it print the error given the input is not >=0?
System.out.print("How many children's tickets do you require? "); int childrensTickets = 0; boolean validChildrenValue = false; while (validChildrenValue == false) { if(aScanner.hasNextInt()) {
I need to check the existence of email accounts before sending them mails to avoid going to a blacklist for sending to non real accounts.
I was thinking on (SSL)Sockets and smtp commands but I cant get it to work properly I am shooting in the dark here...
I have a JAVA application that sends mail to the people that buy certain things but the information quality is bad, so I must check if the mail exists before sending the mail....
I need to check in my java class the status of the javascript (whether it's enabled or disabled) and based on that few validations will be performed at server side.
If have to use noscript, then any small example for xhtml. My project works on Spring web flow.
I am doing an assignment for a college class. We are asked to get user input and decide if it is a valid IP address and then check what class the address is and if it is a public or private address.
So far, I can get the input, and check to see if the numbers are in a valid range. I can also display the IP address to the user. I am having an issue figuring out how to get the program to check the classes and whether they are public or private.
import javax.swing.JOptionPane; /** This program will take user input and calculate whether it is a valid IP address and the class that it belongs to. */
public class shortONE_1 { public static void main(String[] args) { //Variables final int MIN_OC = 1; //Minimum number accepted final int MAX_OC = 255; //Maximum number accepted final int MIN_A = 1; //Min number for class A final int MAX_A = 127; //Max number for class A
I've been asked to create an app for nutritionists to check what their clients are eating.
I've found a database of all foods with nutritional values. In the past I've dealt with databases which just have are just one dimensional, so it's been easy to just create a string array for it. But this is absolutely huge, it's got about 10,000 rows and 30 or so columns, so that's not going to work any more.
The app needs to ask what the client ate at which times, and then save this along with the nutritional values.
What would be the best way to go about storing and calling a database of this size in java?
Should I learn SQL and JDBC to tackle it or is there any easier way?
I have a problem with several java applications. When I start them Java wants to connect to the certificate authority, to check if the certificate is still valid and not on a blacklist.
The problem is: my whole internet is behind a password protected proxy. If I open my browser i get a windows with username and password. I enter it and internet in the browser works. But for Java it isn't working, because I see no point, where I can enter the password and username for the proxy. I can enter the proxy ip and port in the java settings, but not the password and username. So I get a error screen from java, telling me, that java could not connect. I can disable the check in the java settings, but I don't wont that.
Is there a way to tell java, that java uses my proxy with my password and username? I already googled this problem and found nothing except tutorials for connecting with proxy in the java code. But these applications are not from me, I can't change the code ...
Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, then the program displays the following sum:
9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880
That's the question I'm getting and so far all I've got is
import java.util.Scanner; public class Lab4Q3 { public static void main (String[] args) { int keyboard;
I am having trouble figuring out how to check for win in tic tac toe, the way my teacher wants it is with various if statements but im not sure what to put in the parentheses. I think it would be something like
This SHOULD be a simple program, the gist of it is Given an element E and the array A that represents a set X (user input), write a program that determines whetherE is an element of X.I have the array list all set up to take the user input and make zero the last element of the array. I want user to input numbers into array, then have fixed numbers for E and check to see if E is in the Array. I guess I'm not sure how to check the array and see if E is in the array? Here is what I have so far...
import java.util.ArrayList; import java.util.Scanner; import java.util.List; import java.util.InputMismatchException; public class Set { public static void main(String[] args) { List<Integer> userInputArray = new ArrayList<Integer>();
I am having an issue with my swing gui. I dynamically create tabs with information (textfields, checkboxes, combo boxes) and when I select the checkbox it disables or enables a textfield. Now when I select the checkbox it seems to resize everything, specifically my textfields from say 9 columns to probably one. I"m a little unsure why it is doing this but I have a feeling it may be an inheritence issue.
My code is below for my generation of the tabs and of the rest of the information on the gui. The gui is an inner rid layout with a top and bottom pane that are both gridbaglayouts and an outter pane as well. I am thinking I am missing something in the grid layout setup that is causing this.
1. In jsp 1 , i have 3 checkboxes(chkbox1,chkbox2,chkbox3) , if i select check boxes (chkbox1, chkbox2), and click on submit, corresponding two text fields (chkbox1,chkbox2) will have to appear in the next jsp i.e., jsp 2.
2. In jsp 1 , i have 3 checkboxes(chkbox1,chkbox2,chkbox3) , if i select check boxes (chkbox2, chkbox3), and click on submit, corresponding two text fields(chkbox2,chkbox3) will have to appear in the next jsp i.e., jsp 2.
Like this, which ever checkbox i select, corresponding text fields should appear in the subsequent jsp.
I'm trying to come up with a method that would validate each turn a player makes. For a turn to be valid, it has to only contain numbers from 0 to 3(inclusive) and at least one digit must not be 0. Here is what I`ve come up with so far. For example, with "303" as the number and "101" as the turn, the turn would be valid and my method should return true, but it does not.
public static boolean turnIsValid (String number, String turn ){ boolean rep=false; int pos1=0; char min='0'; char max='3'; while(number.length()==turn.length()&&pos1<turn.length()){
I am currently trying to write a method for checking to see if an "agent" in a cell (place in a 2d array) is satisfied. So, the assignment is a 2D array that can have a blank space, an O, or a X as a character that fills a particular space. An agent is satisfied if it has similar characters around it in a percentage that is higher than the threshold. For example, if the threshold was 60% and a cell that had an X in it, had 3 X's around it and 2 O's, then it would be satisfied because 3/5>=60%. For my code, I tried using if and else statements to isolate circumstances in the corner of the grid, the edges, and everything in between.
public static boolean isSatisfied(char[][] tissue, int row, int col, int threshold){ char check= tissue[row][col]; if (check==' '){ return true; } else{ int countx = 0; int count = 0;
I am using form based, declarative security approach. And, when some user, on login form enters user credentials (username and password), he is being redirected to certain/secured jsp page.
Part of that page content is:Hello <%=request.getUserPrincipal().getName().toString()%> You are able to view this page because you are authorized user.You can see that this is implemented using JSP scriptlet. And this works. I would like to use JSTL instead of scriptlet.
So, instead of scriptlet, I put this JSTL code: <c:out value="${requestScope.userPrincipal.name}"/>, but not getting user's username with it. Basically, I don't clearly understand where and how are these objects/user credentials being stored with Form based JAAS.
I would like on JSP page to check if some user is already logged in. So, if there is logged user to display user's name (also with JSTL).Something like this:
<c:if test="${not empty sessionScope.userPrincipal}"> User <c:out value="${sessionScope.userPrincipal.name}" /> </c:if>
Here I tried with sessionScope but still not getting anything.
My program here asks for an unit to choose from (fl.oz, gal, oz, lb, in, ft, or mi), asks how much of it they have, and asks for the unit they wish to convert to (mL, l, g, kg, mm, cm, m, or km).
My program works, refusing to convert from silly conversions such as gal to cm, telling you to re-input if they enter anything other than fl.oz, gal, etc.
The only thing I cannot figure out is if the user inputs something like "foo" when the program prompts the user for how much of the unit they have. My goal is to have the program say something like "That is not a number! Please enter a numerical value."
My current dilemma right now is that if the user inputs something other than a number, it will catch the exception and print a line telling the user it's not a number, except, it does it infinitely (stuck in a loop). Here is my code:
import java.util.InputMismatchException; import java.util.Scanner; public class UnitConversions { public static void main(String[] args) { Scanner s = new Scanner(System.in); double result = 0;
I was wondering if there was a way to check/view messages from my phone. I'm trying to create a program that will be able either read messages from my phone, or reply to them. I'm trying to get this to work for a Window Phone, but I don't know if there is a difference between doing it on a Windows Phone or Android. Most of the topics that somewhat relate to what I'm doing are all Android based.
I've looked at AT Commands, SMS Gateways, but I'm still not sure if it's entirely possible.
How could I check if an index is exist in an array list? I mean, I should enter an integer and it should return me a boolean result that saying whether if that entered value is an index or not.