Partially - I was hoping to get the index of every character individually. So 'abc' would be '123' and then '123' would act as the seed for the psuedo-random number generator. Maybe a for loop isn't...
Type: Posts; User: BenjaminJ
Partially - I was hoping to get the index of every character individually. So 'abc' would be '123' and then '123' would act as the seed for the psuedo-random number generator. Maybe a for loop isn't...
So, instead of:
alphabet.indexOf(tokens[i]);
int result = tokens[i];
it should be
Okay, is that better?
I'm trying to create a PRNG which takes a seed through Scanner.
Here's the (terrible) code:
import java.util.*;
public class Numbers {
Okay, so, my program needs to match this: Maisto Ford Mustang Limited Edition 1:18 Red
with "Mustang" but not to "Ion"
Sample input and output:
INPUT:
Maisto Ford Mustang Limited Edition...
This is the part I updated.
for (int i=0; i<scaleList.length; i++)
if (title.toLowerCase().lastIndexOf(scaleList[i].toLowerCase())!= -1)
{ scale = scaleList[i];
...
Well, another issue has come up. For example with a model of a 'GT500' the program reacts by matching that first with 'GT' and settling with that. I've tried '.contains', I've tried .indexOf != -1,...
You're right, I've reduced the block of if statements to nine lines in total. And the problem, originally, was the way I joined new lines with +s instead of just pressing enter and typing a comma.
I'm writing a program which takes the title of a model car and breaks the elements down into HTML metadata.
All of the car companies (Ford, etc.) are in an array, which is called upon to be...
Yes, sorry, it was a case of curly brace confusion once again.
The premise is a brute force search for an inputted string. Based on the length of the inputted string (1-4) the switch statement executes one of four blocks which should break when it finds the...
Would you mind naming the method? I'm only just starting to learn the String class.
And thanks jdv for the information, much appreciated.
You could try a string array containing every stage of the dot pattern and having a for loop cycle through the elements.
So I'd have the array which would have a .length as the amount of items as chars inputted by the user? Then what would I do with that array? Surely there'd be an amount of possibilities which I'd...
Oh! Excellent. That totally slipped my mind. Why is not giving me an error, in that case? Is there any way of modifying this code so the user can input a string of any length they choose? I assume...
Hi there,
For people to help it's useful if you put [ code=java] [ /code] (without spaces) around your code, and also paste the sample output.
Thanks
import java.io.IOException;
import java.util.*;
public class Guesser {
public static void main(String[] args) throws IOException {
char[] alphabet = "abcdefghijklmnopqrstuvwxyz1234567890...
int[] onetoTen = {1,2,3,4,5,6,7,8,9,10};
int sum = 0;
for (int i=0; i<10; i++) {
sum +=onetoTen[0]++;
System.out.println(sum);
Okay, thank you both that worked fine, does that mean that it needs to be declared in main only? I tried it in main and that worked, but would it work if it were to be declared in another method?
...
There's loads of problems with this. What I'm trying to do.
1) get a program to add the contents of an array together, preferably with a for loop and not the heavy handed version I've tried to...
Thanks for the suggestions but I think that it might be beyond my capabilities right now - I understand the logic but not how to implement it.
public class PasswordGen {
public static void main (String[] args) {
Generator();
}
public static void Generator() {
I just realised the answer myself - the only part looping was the print method, not the random number generator. Everything's solved, thanks guys.
You would want to do this with a for loop, I think.
for (int i = 0; i < 500; i++) {
System.out.println(i);
}
Unless you're practicing while/if, in which case I'm not sure.
I thought I just replied to this, but my post disappeared. Thanks for your concise reply - I have another question; when I put the random number generator in a for loop, it returns the same result...