I'm looking for someone to write a program for me in java. I'll provide the pseudocode for the program below, but i need someone competent with java to write it for me. My understanding of the syntax of java is quite limited, so i can't write it myself. It would also be appreciated if you would heavily comment the program so I can learn what the different parts are, and the correct syntax for various commands. Can anyone help me?
Load file containing six arrays
First array contains number between .5 and 2.0
Second array contains strings containing questions
Third array contains correct answers
Fourth through sixth array contains strings contain incorrect answers
Create array same size as first array containing all 1s
Loop
Sum the all the values in the first array multiplied by their equivalent number in generated array
Generate a random number between 0 and the above value
One at a time, subtract all the values in the first array multiplied by their equivalent number in the generated array from the random number until it is less than or equal to zero
save the value of the location id of the last number subtracted into another array(q array)
add the value at that location in first array to another variable
set the value at that location in the generated array to zero
go back to loop until variable is greater than or equal to 20
Loop2
ask question at location id saved at first value
randomize answer order
take answer
check to see if time is less than 10 times value in first array for this question
if answer correct and value is less, then subtract .1 from value in first array(cannot be less than .5)
if not, add .2 to value(cannot be more than 2.0)
inform if correct/incorrect and/or on time/too late
repeat above steps for all values saved into q array(goto loop2)
save new values of first array into same file loaded from to start
Put what you have in word form into code. You only need arrays, while loops and if-else statements from the looks of things. I only skimmed though, so I may have missed something.
// This is an Array:
private int[] lolArray = {Array **** 1, Array **** 2, Array **** 3};
//If else statement:
if(cake == lie) { //If cake is a lie.
cake.eat;
} else if(cake !== lie) { //If cake isn't a lie.
cake.bake;
}
//While loop:
while(testInt < 5) { //While testInt is less than 5
System.out.println("testInt is less than 5");
testInt++; //Adds 1 to testInt, so loop ends eventually. Optional.
}
Apologies for any code errors in there, I just quickly typed it up in the forum box.
You've been learning Java for over a month now, don't tell me you can't set up an array yet, or add two numbers?
It's just the array's really. And the fact of, I'm still looking for an example. It helps to be able to see the ways other people do things. Keeps me from getting stuck on one track. And, school has been in the way, I don't get alot of time to work on java right now.
Rollback Post to RevisionRollBack
"BTW is made in the spirit that Minecraft, like bondage, gets better as you become more restrained."
If you want examples of how to do X in language Y, check out Rosetta Code.
Getting stuck on one track would be a huge improvement already. Fire up Google, roll up your sleeves, and write some Java. It's the only way to learn.
First of all I would like to thank you for the link to rosettacode. I have never heard of that site before, and it looks like it could be a valuable resource for me. However, I would disagree on the count of doing being the only way to learn. A very important part of the learning process is to see an example of how something is done/works. I never claimed this was all I was doing to learn java, this is just a part of it.
Rollback Post to RevisionRollBack
"BTW is made in the spirit that Minecraft, like bondage, gets better as you become more restrained."
Well, from personal experience I can say that I learned the little Java I know from a book much more than online tutorials. The rate at which I learned from the book was superior to online tutorials. Just my experience.
Perhaps I should have said "it's the best way to learn" instead.
And of course you need to look at actual Java code to be able to write your own. Why do you think "fire up Google" was step one? Any tutorial will have well-documented examples.
And yes, the tutorial has examples, but they are somewhat simple and directly related only to the current topic. I was hoping for one that was a little more complex. Not much, just a bit. And, I would kinda like to have the program.
I'm not sure what this code is really trying to achieve. It seems to be doing something rather random tbh.
I'd be more interested in what you're trying to achieve, if it's something in particular. I could code it if I so wished, but not sure if you're thinking of the best way of actually doing what you need to do there or not.
It creates a quiz based on a series of questions saved in an array. It doesn't ask the same questions each time, instead it chooses a number of questions based on the difficulty of the questions for the user. The number value is the difficulty modifier for the questions. At least that array needs to have it's values retained between uses of the program.
It creates a quiz based on a series of questions saved in an array. It doesn't ask the same questions each time, instead it chooses a number of questions based on the difficulty of the questions for the user. The number value is the difficulty modifier for the questions. At least that array needs to have it's values retained between uses of the program.
Sorry, I didn't mean to ignore you, I just got caught up in what I was saying to Nocte. But anyway, your code is missing some pieces of what I need.
Sorry if I appeared rude, too. I gave you the basics there, so you can build upon that. The way to make a random question 'generator' is as follows (at least this is how I would do it):
import java.util.Random;
public class Test {
public static void main(String[] args) {
String[] question = {"Question 1", "Question 2", "Question 3", "Question 4"};
Random randomObject = new Random();
//The following prints the array, with the array index being random.
//This is what makes it 'random'.
System.out.println(question[randomObject.nextInt(4)]);
}
}
I tested it and it works, hope that helps!
Rollback Post to RevisionRollBack
If you can't strive for perfection, what can you strive for?
Apologies for any code errors in there, I just quickly typed it up in the forum box.
It's just the array's really. And the fact of, I'm still looking for an example. It helps to be able to see the ways other people do things. Keeps me from getting stuck on one track. And, school has been in the way, I don't get alot of time to work on java right now.
First of all I would like to thank you for the link to rosettacode. I have never heard of that site before, and it looks like it could be a valuable resource for me. However, I would disagree on the count of doing being the only way to learn. A very important part of the learning process is to see an example of how something is done/works. I never claimed this was all I was doing to learn java, this is just a part of it.
Aye, I don't doubt it. But, alas, I am broke.
And yes, the tutorial has examples, but they are somewhat simple and directly related only to the current topic. I was hoping for one that was a little more complex. Not much, just a bit. And, I would kinda like to have the program.
It creates a quiz based on a series of questions saved in an array. It doesn't ask the same questions each time, instead it chooses a number of questions based on the difficulty of the questions for the user. The number value is the difficulty modifier for the questions. At least that array needs to have it's values retained between uses of the program.
Sorry, I didn't mean to ignore you, I just got caught up in what I was saying to Nocte. But anyway, your code is missing some pieces of what I need.
Sorry if I appeared rude, too. I gave you the basics there, so you can build upon that. The way to make a random question 'generator' is as follows (at least this is how I would do it):
I tested it and it works, hope that helps!