Is there a reason why this error is occurring? I can't identify what's causing it to happen.
Java Code:
package tictac1; import java.util.*; public class TicTacToe{ //Instance variables private char[][] board; //2D array of chars for the board public TicTacToe(){ //creates a board where each space holds whitespace board = new char[3][3]; for (int row = 0; row < 3; row ++){
I need to find the Winner using Object Orientation logic I have my old logic from my Tic Tac Toe game but it is not Object Orientated. So I want to convert it and add that code to my GUI Tic Tac Toe. I need to return a winner or tie.
How to start and structure my program because i am fairly new to the program but want to try to make a game. My idea of the game is it generates random numbers between 1-100 for two people and the program compares the two random numbers and declares the player with the higher value the winner like the card game war. Then it would give you an option to try again.
String must be 6 characters, first 3 must be letters, last 3 must be digits..Here is my code:
import java.util.Scanner; public class ValidTicket { public static void main (String[] args){ Scanner in = new Scanner (System.in); String id; int c=' ',i; int letterCount=0, digitCount=0; System.out.printf("Enter ticked id
[code]....
However when I run my program, it does not work:After I enter the string nothing happens.
I am required to make a console calculator that takes the values as strings and turns them into doubles. The user needs to be able to enter something like 3+4+5*9/13 on one line and the application give the answer. As of this point I am currently on at the last section as making the user be able to enter the expression and present the answer. I have added an array list containing + - / * and the same with the numbers 1-9...I now need to actually get the information to all come together. I'm not sure how to do that. I *think* I have all the parts for it to work.
public static void main(String[] args) { String input = ""; // initalize the string boolean isOn = true; // used for the while loop...when false, the // program will exit. final String exitCommand = "Exit"; // exit command
I have some problems about performing regular expression. In the following code, the output as a result is being "valid last name". But in my opinion, it should be "invalid last name". Because "Doe" has not any space, apostroph or any hypen. Look at the regular expression statement: "[a-zA-Z]+([ '-][a-zA-Z]+)*"
package deneme; public class Deneme { public static void main(String[] args) { String lastName = "Mc-Something"; // Mc-Something if(!lastName.matches("[a-zA-Z]+([ '-][a-zA-Z]+)*")) System.out.println("Invalid last name"); else System.out.println("Valid last name"); } }
I know that the asterisk qualifier means character(s) in any number.(Is this wrong?) So for "Mc-Something", 'M' corresponds to [a-zA-Z], 'c' corresponds to +, - corresponds to [ '-], 'S' corresponds to [a-zA-Z], "o" corresponds to +, and finally "mething" corresponds to *, doesn't they? But for "Doe", there is no any space, apostroph or hypen.
I am creating a JSF 2.0 project, and I am facing a problem when using the rich:pickList (richfaces 4) component with a custom converter.
I can populate the picklist left column rightly. But, when I move some item from left list to the right (by clicking in the pickList "add" button) and I try to submit the form that contains the pickList, I receive the following error message:
"mainForm:picklist: Validation Error: Value is not valid"
I have already overridden the methods equals and hashCode in my model class (Pessoas.java), but the problem remains.
I am working on allowing a user to enter an ID # using JOptionPane. If the ID is valid, then it will display the ID#, student name, and GPA. If it is not valid, then the window should pop up again to allow the user to enter a valid ID. I have managed to get that far.
I am struggling with once a valid ID # is entered, how do I get the loop to stop? I have tried several different ways, but the code below is the most recent one, and it is still not working!
import javax.swing.*; public class StudentIDArray { public static void main(String[] args) { String enteredID; int idNumber; int x = 0;
Make a password rule, and take input of the password from the user and compare the password with your rule, if the user had entered valid password then print the message, password valid, else the password is invalid for (the whatever) reason.
Rules:- -Length 8-12 -Should have one numeric character -No Special Character -Atleast one UPPERCASE letter
PHP Code:
import java.util.*; import java.lang.String; import java.lang.Character; public class PasswordSpence { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Please enter a Password: "); String password = input.next(); if (isValid(password)) {
I am currently working on an application with java and I want to do is upload and download details in .xlsx file. Uploading process is successfully worked but the problem is that when I download the file .xlsx with details at opening the file it gives me the following message :
Excel cannot open the file '(filename)'.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Write a program reads in a series of passwords into an array. Store 10 passwords. After creating the password array, have the reader enter a password and see if it is in the array. Fi it is there, print "Valid password" and if it is not there, print "Invalid password."
This is what i have so far
Java Code: public class passwordMatch { public static void main (String [] args){ String [] myArray = new String[10]; myArray[0] = "jasmine22"; myArray[1] = "jackson77";
[Code] .....
It doesn't compile. It gives me error saying .class expected next to String.myArray[]
I'm trying to do a user validation loop that runs until the user enters a valid binary, q, or Q. I think the rest of my program should work as intended, but here is the areas of concern:
public static boolean isBinary(String num) //Check if the entry is binary { for(int i = 0; i < num.length(); i++) { if(num.charAt(i) != 0 || num.charAt(i) != 1){ return false;
I'm doing a project in netbeans. I have to make a on-line bank with all the GUI. In the middle i got stuck with the classcastexception..
public class Banca { public static void main(String[] args) throws IOException, ClassNotFoundException { // dati dei clienti Anagrafica c = new Anagrafica();
[code]...
And here's the class of the activities of an account.. I'm not posting my classes Conto( Bankaccount) & Movimento (Activity) because those two already do what they should..
I'm trying to do the following and my code is putting me in a loop and not allowing me to input a valid entry after using an invalid #.I ask the user for input which contains a loop if the user doesnt use the correct information, however the loop doesnt allow the user to input if the entry fails the which statement
import javax.swing.JOptionPane; // Needed for JOptionPane class public class LoanQualifier { public static void main(String[] args) { double salary; // Annual salary double yearsOnJob; // Years at current job String input; // To hold string input
// Get the user's annual salary. input = JOptionPane.showInputDialog("Enter your " +
I have this code running correctly in Eclipse all except that it seems no matter where I declare, highest, lowest, average they always seem to stay at "0". I have a feeling the location of the Initialization is not the error since I have tried moving it to inside differ loops.
Stipulations on writing this code are:
Note: You do not need to use array to save each input score for this lab. A Single loop to read in each grade, compare with the current highest grade, lowest grade, and calculate the running sum at the same time.
import java.util.Scanner;
/*Write a program that prompts the user to enter the total number of students first. *Then ask the user to input each student’s grade and use loop statements to read in each grade. *Check input grade to make sure 0<=grade<=100, if the user input any other number, print out warning message and ask the user to input a new grade. Display the highest score, the lowest score and the average. */
public class LoopStatements { // Main Method public static void main(String[] args) { // Initialize int grade = 0; // grade value
How to use a constructor with parameters where the user inputs the information? I'm doing a problem where I create a Delivery class that accepts arguments for the year, delivery number within the year, distance code (1 for short distance, 2 for long), and weight of package. The constructor is supposed to also determine the eight digit delivery number (combining the year and delivery number, like 20140054 for this year, package #54).
I know I'm not close to being done but I'm struck on the application with the constructor parameters. If I'm asking the user to input the information, does that mean I have to create a no argument constructor so it will compile? Right now it won't compile because it's asking for the parameters but I can't put them.
This is the class:
public class Delivery { int year; int delNum; double weight; int code;
[Code] .....
And the error is:
CreateDelivery.java:22: error: constructor Delivery in class Delivery cannot be applied to given types; Delivery firstDelivery = new Delivery(); ^ required: int,int,int,double found: no arguments reason: actual and formal argument lists differ in length 1 error
I'm writing a temperature converter for class, and I'm done but one piece that I can't wrap my head around.My input scale radiobuttons work fine, but the output scale radiobuttons don't deselect automatically. They're two different button groups and I wrote them identical save for the variable names.
Total IS those numbers. But question[10] will not cooperate with me and it's getting a bit aggravating as I can't find a logical reason for it to be doing that.how to perhaps lock the value of total and sTotal after 10 button clicks from any?
Write a method called isSorted that accepts an array of real numbers as a parameter and returns true if the list is in sorted (nondecreasing) order and false otherwise. For example, if arrays named list1 and list2 store {16.1, 12.3,22.2, 14.4} and {1.5, 4.3, 7.0, 19.5, 25.1, 46.2} respectively, the calls is Sorted(list1) and isSorted(list2)should return false and true respectively. Assume the array has at least one element. A one-element array is considered to be sorted. public class thirfd {
I have spent some time thinking about the program, and realize I need two loops-- 1 that keeps track of bricks in a row and 1 that keeps track of the number of rows as the Pyramid rises in height. The Pyramid is supposed to be centered on the bottom of the screen. Three CONSTANTS have been required:
I tried breaking the scope of things down by trying step-wise refinement. But, I got bogged down. When I tried a method where both loops were included, I got limited success. For some reason, my equation to center along the x axis seems to be doubling the number of bricks. But, the correct number of total rows of bricks was a success. Also, the Pyramid was centered on the bottom of the screen. Another frustrating failure was that the number of bricks would not decrease as the new layers were created. My thought process was instead of using a loop that counts up (i++) I would use a loop that counts down (j--) which I thought would reduce the number of brick in each row as the "y" coordinate was reduced by each count of the BRICK_HEIGHT.
This is the code that "works". Whenever I add the (j--) the results are NOT what I expect.
/* * File: Pyramid.java * Name: * Section Leader: * ------------------ * This file is the starter file for the Pyramid problem. * It includes definitions of the constants that match the sample run in the assignment, * but you should make sure that changing these values causes the generated display to change accordingly. * [code].....
I am writing a code in which a user inputs data as a string and that data must be verified as a valid number. A valid number is anything from 0-100. Then all valid numbers are converted into double numbers.
I am having trouble in how to write the validation part of the code.
Is it suppose to be an if, else statement? And if so how is it suppose to be validated?