Update Sequence Of Stars According To Actual English Word And Guess Character
Jan 12, 2014
Below is part Two the method I need creating:
This method updates the sequence of stars according to the actual English word and the guess character.
public static String updateSecretWord(String secretWord, String englishWord, String guessedChar)
{
}
Below is the example of how it should look like when I call it
updateSecretWord(“*****”, “Hello”, “h”) = h****
updateSecretWord(“h****”, “Hello”, “o”) = h***o
updateSecretWord(“he**o”, “Hello”, “e”) = he**o
View Replies
ADVERTISEMENT
May 27, 2014
I have separated characters into an array that can be accessed from any method, however, when I try to compare the inputed guess to the computers random sequence, the counter always comes back as 0 (the comparison occurs in the checkColour method).
Java Code:
package mastermind;
import java.util.Scanner;
/**
* Program Description: play a game of mastermind versus the computer
*/
public class Mastermind {
private static int block1, block2, block3;
private static String blockColour1, blockColour2, blockColour3;
[Code] ....
The counter is called colourCorrect.. But I think the problem lies more in me converting the strings (input and computerGuess) into char arrays, as if I output the values at position in the array, I get numbers (but the numbers are not character values from the ascii table).
View Replies
View Related
Oct 21, 2014
any method or common algorithm to change a number taken from input to the word for that number? Such as input being "4", output would be "four", at least up to 59 as the larger program I'm trying to make involves time
View Replies
View Related
Apr 5, 2015
I am making a java program that translates English into Pirate. I need working with the Word Pair class. I'm not sure what needs to be passed to the default constructor. And how to do the method that will take the words and pair them. here is my code and the dictionary file
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class PirateTranslator {
public static void main(String[] args)
[Code] .....
View Replies
View Related
Mar 16, 2014
i need a password program that does the following:
- only shows the character count
- toggles between seeing the actual letters and character count in the text field with a button
i don't know how to update the character count as the user is counting.i read the oracle tutorial, and i have a vague idea that i'm supposed to use Document Listener but i'm quite clueless here.for the second part i'm thinking about using white space for the masking character and unmasking the field.
View Replies
View Related
Dec 27, 2014
public static void main(String[] args) throws FileNotFoundException, IOException{
// TODO code application logic here
FileReader fr = new FileReader("gautam.txt");
BufferedReader br = new BufferedReader(fr);
int line = 0;
int word = 0;
int character = 0;
String s;
while((s=br.readLine())!=null)
[code]...
how to count the character from file
View Replies
View Related
Jun 27, 2014
I am trying to make a java program which should count the occurrences of a specific character in a string. I have 1 error - "cannot find method charAt(int)". Here is what I have.
import java.util.Scanner;
public class ch4q5 {
public static void main(String[] args) {
String input ;
String t ;
int c = 0;
[Code] ....
View Replies
View Related
Feb 9, 2015
I am trying to create an array list without using the built in arrayList class that java has. I need to start the array being empty with a length of 5. I then add objects to the array. I want to check if the array is full and if not add a value to the next empty space. Once the array is full I then need to create a second array that starts empty and with the length of the first array + 1.
The contents of the first array are then copied into the new array without using the built in copy classes java has and then the new array ends up containing 5 elements and one null space the first time round. The first array is then overwritten with the new array containing the 5 elements and the null space. The process then starts again adding values until the array is full which will be 1 more value then recreating the second array empty and the length of the first array + 1. This is my attempt at creating this but I have run into multiple problems where I get only the last value I added and the rest of the values are null:
public class MyArrayList {
public Object arrayList[];
public MyArrayList(Object[] arrayList) {
this.arrayList = arrayList;
[code]...
View Replies
View Related
May 14, 2014
I have a strange behaviour when trying to update a bean. Here is the edit page:
<h3>Edit Post</h3>
<div class="row">
<h:form>
<div class="small-3 columns">
<label for="right-label" class="right inline">Title</label>
[Code] ....
Here is the bean class:
package com.airial.controllers;
import com.airial.domain.Post;
import com.airial.service.PostService;
import com.ocpsoft.pretty.faces.annotation.URLMapping;
import com.ocpsoft.pretty.faces.annotation.URLMappings;
import org.springframework.beans.factory.annotation.Autowired;
[code]...
postToUpdatet is always NULL. Why the title property is not binded ? What is wrong here ?
View Replies
View Related
Feb 2, 2015
i want to have a JLabel that could "robotically" type words character by character.
View Replies
View Related
Nov 21, 2013
I use Eclipse (kepler version, with JDK 7) on MacBook Pro (Lion).I want to overwrite a line printed on my console. I used "" for that. I was expecting the cursor to go to the beginning of the line. Instead, it is going to the next line.
Code:
System.out.print("Superman
Sober");
Expected Output:
Soberman
Actual Output:
----------------
Superman
Sober
View Replies
View Related
Jan 11, 2014
In the following Java Code:
public static void f() {
int n = 5;
p(n, 2 * n);
}
public static void p(int a, int b) {
int x = 1;
q(x, a + b);
}
public static void q(int x, int y) {
int z = x + y;
x = 0;
...
} mh_sh_highlight_all('java');
When we write x = 0; that refers to the formal parameter int x and hence it's the formal parameter that changes value. why isn't the value of the actual parameter also changing?
View Replies
View Related
Jan 31, 2014
I wrote a Chess game that uses socket to connect to another computer, and allow player vs player and player vs computer game sessions.
However, there is a problem which I noticed.
When you get the IP address of the computer in which the program is running, you are not getting the computer's actual IP, you are getting the Router's IP.
Is there a way to get around this.
So the problem is that when I go to another computer, located in a different house or lets say from my school, the program cannot connect back to my home IP, because it uses the router's ip, not the computer's ip I am running the server program.
Is there a way to get the Computer's IP, not the router's ip when summoning or invoking the get IP address method from the socket class?
When I say that the socket class is acquiring the router's ip, well that's done without my interfering...I don't know why it does that, it is somehow recognizing the router and not the computer.
The thing is that the server program is written that any client program is able to connect to the home server.
But when I run the program from a different location other than the current home, the sockets don't connect because it is somehow recognizing the router's ip not the computer's ip.
View Replies
View Related
Jun 3, 2014
public static void main(String[] args) {
System.out.println("VALUE Types");
int i = 5;
int j = 11;
System.out.println("i = " + i + ", j = " + j);
[Code] ....
Questions based on the code:
1. Identify all of the actual parameters in the code provided.
(Is it just i, j iArray and jArray)???
2. Identify all of the formal parameters in the code provided.
3. What is displayed in the third println statement?
i = 11, j = 2001
4. What is displayed in the fifth println statement?
iArray = 6 7 2001 9 10, jArray = 6 7 2001 9 10
View Replies
View Related
Jul 2, 2014
So I'm studying for a test i have coming up on recursion so i was playing around with it. I ended up making a pattern of stars that look that such :
*
**
***
The code i had for that was
public void makePattern(int size){
if(size == 0){
System.out.println();
}
else if(size > 0){
System.out.print("*");
makePattern(size - 1);
}
}
I was wondering if i wanted to expand on this and make it do something like
*
**
***
**
*
What condition would i have to add i was struggling trying to figure it out...
View Replies
View Related
Mar 3, 2015
What I am trying is find the XOR value between charcters of a String here is my code
public static void main(String[] args) {
System.out.println(grayCode("100"));
}
public static String grayCode(String input){
StringBuilder temp=new StringBuilder();
temp.append(input.charAt(0));
for(int j=1;j<input.length();j++){
char previous=input.charAt(j-1);
char current=input.charAt(j);
char xorVal=(char)(previous^current);
temp.append(xorVal);
}
return temp.toString();
}
but I am not getting actual XOR value of two charcters that I am trying to get.
View Replies
View Related
Apr 27, 2015
I have built a binary tree, from a file. In each node, I am storing each word as a string, and an int frequency for each time the word occurs. For the assignment, I need to find how many words occur only once in the file. I wrote the program, but for some reason I am getting a number different from what my professor is expecting.
As far as I know, this file has loaded into the tree correctly, because all of my other answers in the assignment are correct. What am I doing wrong?
public void findUnique() {
System.out.println("There are " + findUniqueWords(root, 0) + " unique words.");
}
private int findUniqueWords(Node subTree, int uniqueCount) {
// Base Case: At the end of the branch
if(subTree == null){
return uniqueCount;
[Code] ....
View Replies
View Related
Apr 30, 2015
I just recently started programming and came across the star patterns which normally I am able to do extremely quickly except with this one. I am trying to make a hourglass but I seem to only be able to make the top of it. How to do the opposite so I can finish the hourglass.
package hourglass;
class Hourglass {
public static void main (String[] arguments){
for(int j=1;j<=5;j++) {
for(int i=1;i<=j;i++)
[Code] .....
View Replies
View Related
Nov 23, 2014
KtMok1t.jpg
Below is what I go so far, but how to do star C and E.
public class PrintTriangle
{
public static void printStars (int star)
{
for (int number = 0; number < star;number ++)
{
System.out.print("*");
[Code] ....
View Replies
View Related
May 7, 2014
I have an applet that uses JPanels to draw images in. I want to include actual jpgs now instead. The applet points to a .jar file. I want to use any number of images here, do I have to include them all in the jar file or is there another way to "point" to them (like html)?
View Replies
View Related
Apr 30, 2014
I have a question about query execution strategy ...
Scenario: let's suppose I've to query a table with a query like
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = ? AND F2 = ? AND F3 = ?.
I need to execute this query changing parameters' actual values in a combinatorial way, until a combination gives back at least one row or all combinations are unsuccessfully tried. For instance, I may have this sequence of values:
(V1,V2,V3);
(V1,V2,"");
(V1,"",V3);
(V1,"","");
where V1, V2, V3 may by string values and V1 is always present, not null, and not blank in each combination.
A first strategy may be to prepare the statement, clear the parameters each time I execute the query, until stop condition is met.
I wonder if may be more efficient transform the query into
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = V1
and cycling over the cursor and, for each cursor row, verify if the returned tuple (F1,F2,F3) matches the combination (V1x,V2x,V3x). When at least 1 rows matches, or all combination are done, I'll exit iteration.
View Replies
View Related
Mar 13, 2015
The intentions of this program is to prompt a user to enter a file name, and then reads the file. The program will prompt the user to enter a word that needs to be corrected. So lets say I have a text file containing "My name is OP and I Like goind to the Park!" I want to change "goind" to "going",
Now, my second method "isSimilar" executes a similar word with more than one same letter and same length, but I dont know how to execute that whole thing in my third method "correctThisLine" . How I can call that isSimilar method and read in that text file and change that word into that?
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class WahidMuhammadA3Q2{
String fileName = "AutoCorrectMe.txt";
public static void main (String [] args){
[Code] ....
View Replies
View Related
Aug 19, 2014
I am looking for java codes to generate a word document based on a word template, basically, I have a word template created and in my local path, the template has a proper format with some fields which will be filled in after java codes ran. The java codes will fetch one record from a table, and open the word template and then fill the fields in the word template, and created a new word document and save it in another folder.
I found this example: [URL] which is similar except it uses xml template instead of word template, how to make it work to change the template from xml to word (docx) template?
View Replies
View Related
Mar 12, 2014
Here is a link to the program: [URL] ....
I am trying to model a galaxy so that I have multiple stars certain distances away from each other and with different masses.
The accretion and than cylinder expansion happens with just about every galaxy.
I have a few questions.
First My computer only runs this if the number of particles is in the 500s. If that's the case How can I increase the probability that I will when I get to it have a red giant?
Second how can I modify this so that I have a timescale during which white dwarfs form from some stars and you see in the single stars either no supernova or nova just degeneration or a type 2 supernova and in binaries a type 1a supernova which is like a type 2 supernova of 1 star when it is a red giant, that giant becoming a white dwarf, the other star becoming a red giant, and then the white dwarf sucking gas from the giant until it explodes and ejects its companion?
Third how can I make this compacted and taking up less space in case I want to expand it to a few galaxies or even start with a big bang?
Basically what I am asking is how can I make this like a universe?
View Replies
View Related
Apr 12, 2014
Am stuck in a problem that asks to write a program using nested for loops to draw a V-shape of height "n" entered by the user with stars .
View Replies
View Related
Feb 26, 2014
This is supposed to be a method that adds stars after each item in the list.
Java Code:
import java.util.ArrayList;
public class ClientProgram {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<String>();
list.add("the");
[Code] ...
I'm guessing it's because list.size() changes, though but it should only find that value in the beginning, so it shouldn't be a problem?
View Replies
View Related