• What Do You Need Help With? V6
    7,544 replies, posted
Does anyone happen to know the best ways to programatically charge a debit/credit card? I've looked at [url=https://stripe.com/]Stripe[/url], ACH transfers, and places like [URL="http://authorize.net"]authorize.net[/URL] but I have no idea how or what the best option is. I'm looking at developing a basic POS system just for kicks and was curious how existing systems go about this. Thanks.
[CODE] #Dice Roller import random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return: exit(0) def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll == "4" or "four" or "Four": FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar".") elif DiceRoll == "6" or "six" or "Six": SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in", SixVar".") elif DiceRoll == "12" or "twelve" or "Twelve": TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in", TwelveVar".") else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat() [/CODE] i'm getting an "expected an indented block" error on line 8 - "return:", any solutions? i've set my indentation width to 4 spaces and manually typed it all out as the previous copy had other indentation errors. sorry for my shite code btw
[QUOTE=Hamsteronfire;44477079][CODE] #Dice Roller import random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return: exit(0) def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll == "4" or "four" or "Four": FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar".") elif DiceRoll == "6" or "six" or "Six": SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in", SixVar".") elif DiceRoll == "12" or "twelve" or "Twelve": TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in", TwelveVar".") else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat() [/CODE] i'm getting an "expected an indented block" error on line 8 - "return:", any solutions? i've set my indentation width to 4 spaces and manually typed it all out as the previous copy had other indentation errors. sorry for my shite code btw[/QUOTE] Is this Python? If so, then you have multiple syntax errors. I think the best way to learn is to fix your own mistakes, so I won't point them all out. However your "expected an indented block" error is because return is not used that way. To return something you need to do: [code]def ExampleFunc(x): a=x+10 return 100*a [/code]
[QUOTE=Anderen2;44477137]Is this Python? If so, then you have multiple syntax errors. I think the best way to learn is to fix your own mistakes, so I won't point them all out. However your "expected an indented block" error is because return is not used that way. To return something you need to do: [code]def ExampleFunc(x): a=x+10 return 100*a [/code][/QUOTE] yeah it's python [code]def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return exit(0)[/code] now i'm getting a syntax error but IDLE is not highlighting the area of error [editline]7th April 2014[/editline] okay so I have this now, but I'm getting an "expected indentation block still" [code=python]#Dice Rollerimport random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar".") elif DiceRoll in ("6", "six", "Six"): SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in", SixVar".") elif DiceRoll in ("12", "twelve", "Twelve"): TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in", TwelveVar".") else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat()[/code]
[QUOTE=Hamsteronfire;44477159]yeah it's python [code]def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return exit(0)[/code] now i'm getting a syntax error but IDLE is not highlighting the area of error[/QUOTE] Well, first of all you should use raw_input instead of input. This is because input makes python evaluate whatever you type in. You could try this by entering 1+1, UserInput would then be 2. Also, when you type yes with your code, then python would complain about not finding an variable called yes. Also, I think you are misunderstanding what return does. After what I see in your code, then you do not need return there. Return is an statement which makes the function return a value to the caller. raw_input is an example of an function which does this. This is not how the function for raw_input looks like, but its simpler to explain this way (psuedo-code): [code]def raw_input(prompt): print prompt return whatever_the_user_typed[/code] This will then return what the user typed to whoever that called the function, which in your case is UserInput [editline]7th April 2014[/editline] [QUOTE=Hamsteronfire;44477159] [editline]7th April 2014[/editline] okay so I have this now, but I'm getting an "expected indentation block still" [code]#Dice Rollerimport random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == "Yes" or "yes": return def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar".") elif DiceRoll in ("6", "six", "Six"): SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in", SixVar".") elif DiceRoll in ("12", "twelve", "Twelve"): TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in", TwelveVar".") else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat()[/code][/QUOTE] It would be better if you copy-pasted the whole error and traceback, as it's much easier to help you that way. I'm not sure if its an issue with your paste, or the code but the first thing I see is that you haven't indented the if, elif and else statements. After each ":" the rest of the code that belongs should be indented. Ex. [code]if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar)[/code]
[QUOTE=Anderen2;44477234]Well, first of all you should use raw_input instead of input. This is because input makes python evaluate whatever you type in. You could try this by entering 1+1, UserInput would then be 2. Also, when you type yes with your code, then python would complain about not finding an variable called yes. Also, I think you are misunderstanding what return does. After what I see in your code, then you do not need return there. Return is an statement which makes the function return a value to the caller. raw_input is an example of an function which does this. This is not how the function for raw_input looks like, but its simpler to explain this way (psuedo-code): [code]def raw_input(prompt): print prompt return whatever_the_user_typed[/code] This will then return what the user typed to whoever that called the function, which in your case is UserInput [editline]7th April 2014[/editline] It would be better if you copy-pasted the whole error and traceback, as it's much easier to help you that way. I'm not sure if its an issue with your paste, or the code but the first thing I see is that you haven't indented the if, elif and else statements. After each ":" the rest of the code that belongs should be indented. Ex. [code]if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in", FourVar)[/code][/QUOTE] [code]#Dice Roller import random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == ("Yes", "yes", "y"): return def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in {}".format(FourVar)) elif DiceRoll in ("6", "six", "Six"): SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in {}".format(SixVar)) elif DiceRoll in ("12", "twelve", "Twelve"): TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in {}".format(TwelveVar)) else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat()[/code] It's working, but now I need the Roller to end after declining to try again. [editline]7th April 2014[/editline] Any chance I could cut the code down, and streamline it? [editline]7th April 2014[/editline] [thumb]http://i.imgur.com/UlZFZZL.png[/thumb] for reference, if it helps
[QUOTE=Hamsteronfire;44477431][code]#Dice Roller import random #imports the random feature, allows randomisation of given values def RollRepeat(): UserInput = input("Do you want to try again? Type Yes or No.\n") if UserInput == ("Yes", "yes", "y"): return def RollFunc(): DiceRoll = input("Which sided dice would you like to roll, a 4, 6 or 12 sided dice?\n") #asks the user for their choice of dice if DiceRoll in ("4", "four", "Four"): FourVar = random.randint (1, 4) print("You have rolled a four sided die, resulting in {}".format(FourVar)) elif DiceRoll in ("6", "six", "Six"): SixVar = random.randint (1, 6) print("You have rolled a six sided die, resulting in {}".format(SixVar)) elif DiceRoll in ("12", "twelve", "Twelve"): TwelveVar = random.randint (1, 12) print("You have rolled a twelve sided die, resulting in {}".format(TwelveVar)) else: print("Not a valid input.") RollFunc() while True: RollFunc() RollRepeat()[/code] It's working, but now I need the Roller to end after declining to try again. [editline]7th April 2014[/editline] Any chance I could cut the code down, and streamline it?[/QUOTE] The return statement you have in RollRepeat has no use, as it's not returning anything, to anyone. What you are looking for is the exit(0) that you had before. exit(0) quits the application cleanly with status code 0 (Meaning that the application ran successfully). Also, well no there is not much to cut down or streamline. For a beginner (?) in Python then this is a great code. You could however use string.lower to make it better to use, aswell as cutting down possible answers. string.lower makes whatever the text is into lowercase, which makes it easier to handle later in the code. Ex. [code] def RollRepeat(): UserInput = raw_input("Do you want to try again? Type Yes or No.\n") if UserInput.lower() in ("no" or "n"): exit(0) [/code]
[QUOTE=Anderen2;44477495]The return statement you have in RollRepeat has no use, as it's not returning anything, to anyone. What you are looking for is the exit(0) that you had before. exit(0) quits the application cleanly with status code 0 (Meaning that the application ran successfully). Also, well no there is not much to cut down or streamline. For a beginner (?) in Python then this is a great code. You could however use string.lower to make it better to use, aswell as cutting down possible answers. Ex. [code] def RollRepeat(): UserInput = raw_input("Do you want to try again? Type Yes or No.\n") if UserInput.lower() in ("no" or "n"): exit(0) [/code][/QUOTE] yeah definitely beginner, but thanks for the help
Why does this work? [cpp]glm::vec2 diff = glm::vec2(5,5) - (5,5);[/cpp] Or rather compile, since it doesn't really work.
Howdy people. I have a question and I have a feeling it's a really simple question, but I'm sleep deprived and can't really think. I need to write a program with vectors that keeps track of the state of a door (open, closed). 200 doors, starting with 2, every second door swaps states, then every third door, then every fourth, etc. When it's done I need to list the closed doors. I have a few ideas about how to approach this but I have a feeling there's an easier way that I just can't figure out. Options: 1) make two vectors, one for open and one for closed, and just push numbers around as i run through the numbers. would work but sounds inefficient. 2) Make one and just run through the numbers and change the state. I'm not sure I can do that with vectors, I'm a bit rusty. Can vectors store an object and an associated boolean? I'm assuming not but from what I've heard apparently vectors are magical so for all I know that would totally work. I guess I could make parallel vectors.... Any input is appreciated, in the meantime I'll continue to just slog through it and figure it out.
[QUOTE=Zinayzen;44482019]Howdy people. I have a question and I have a feeling it's a really simple question, but I'm sleep deprived and can't really think. I need to write a program with vectors that keeps track of the state of a door (open, closed). 200 doors, starting with 2, every second door swaps states, then every third door, then every fourth, etc. When it's done I need to list the closed doors. I have a few ideas about how to approach this but I have a feeling there's an easier way that I just can't figure out. Options: 1) make two vectors, one for open and one for closed, and just push numbers around as i run through the numbers. would work but sounds inefficient. 2) Make one and just run through the numbers and change the state. I'm not sure I can do that with vectors, I'm a bit rusty. Can vectors store an object and an associated boolean? I'm assuming not but from what I've heard apparently vectors are magical so for all I know that would totally work. I guess I could make parallel vectors.... Any input is appreciated, in the meantime I'll continue to just slog through it and figure it out.[/QUOTE] Why not just a vector of bools which are true for open, false for closed or something. Do the state-swapping and then just print out every door that is false?
That...might work, actually. Is there a way to output which "cell" (I know they're not cells, those are arrays but I'm tired) is being accessed? That way if I output the ones that are false it would output like "1 3 17 etc"? I don't 100% remember how vectors work.
[QUOTE=Zinayzen;44482090]That...might work, actually. Is there a way to output which "cell" (I know they're not cells, those are arrays but I'm tired) is being accessed? That way if I output the ones that are false it would output like "1 3 17 etc"? I don't 100% remember how vectors work.[/QUOTE] Since you're going to be iterating through them, you will know the key you are at so just output that number. For example: [cpp]for(int i =0; i<200; i++){ if(!vector[i]) std::cout<< i << " "; }[/cpp]
that will work, thanks. I had a feeling it was a reasonably simple answer but i'm tired. vectors are pretty sweet, i have to say. [editline]7th April 2014[/editline] one other question. is there a fast way to fill the vector with numbers in numerical order? I know you can do std::fill but I'm not sure my program supports C++11 or whatever it is. [editline]7th April 2014[/editline] fuck it, for loop it is
[QUOTE=Zinayzen;44482211]that will work, thanks. I had a feeling it was a reasonably simple answer but i'm tired. vectors are pretty sweet, i have to say. [editline]7th April 2014[/editline] one other question. is there a fast way to fill the vector with numbers in numerical order? I know you can do std::fill but I'm not sure my program supports C++11 or whatever it is. [editline]7th April 2014[/editline] fuck it, for loop it is[/QUOTE] A loop would work, but it seems std::fill is C++03 so you can use that too. Also what IDE do you use? If it's VC12+ then I'm sure it supports most C++11 features, except the really neato ones.
well, this got messy fast [cpp] vector<bool> doors (200, 0); vector<bool>::iterator doorsIterator; ... //Increases iterator gap for(i = 2; i < 200; i++) { //Flips every appropriate boolean based on iterator gap for(doorsIterator = doors.begin() + i; doorsIterator < doors.end(); doorsIterator += i) { if(doors.at(*doorsIterator) == 0) { //If set to 0, set to 1 doors.at(*doorsIterator) = 1; cout << "Changed to true" << *doorsIterator << endl; } else { doors.at(*doorsIterator) = 0; cout << "Changed to false" << *doorsIterator << endl; } } }[/cpp] The two cout statements are for debugging but they both seem to point to 0, which means I fucked up the loop somehow but I don't know how.
I am confused at what you are trying to accomplish. Your current code will start at 2 and go to 200, then using that number it will start offset by it and then flip every door offset by it again. Is this correct? Also, your iterator check should be doorsIterator!=doors.end(); You are running the risk of going out of bounds, as you could increment by say 60 four times without tripping off any alarms. Ontop of this, when you do door.at(*doorsIterator) you are dereferencing the value of the iterator, which will either be 0 or 1 as it is a bool. What you meant to do is *doorsIterator == 0 and *doorsIterator = 0. I would say you should instead just use a simple for loop instead of using an iterator, that way you can check for bounds (i< 200) and also have less issues with dereferencing and all that.
I fixed it. I'm not sure why exactly I thought it would work before, but it works now. I was told to design it in such a way that I don't necessarily know the bounds, which I suppose is the point of vectors anyway.
[QUOTE=Zinayzen;44483021]I fixed it. I'm not sure why exactly I thought it would work before, but it works now. I was told to design it in such a way that I don't necessarily know the bounds, which I suppose is the point of vectors anyway.[/QUOTE] You could just use vector.size() then. Anyway I didn't know you could just compare iterators like that, but I guess it makes sense.
That's what I ended up doing, yeah. Somehow I mixed up vector.size() and vector.end(). That didn't work very well.
Need help here for an assignment: [url]http://stackoverflow.com/questions/22925498/opengl-some-textures-are-wrong-color[/url] It's OpenGL
[QUOTE=Over-Run;44483142]Need help here for an assignment: [url]http://stackoverflow.com/questions/22925498/opengl-some-textures-are-wrong-color[/url] It's OpenGL[/QUOTE] Are you sure you are loading your image right ? or sending it correctly to openGL ? your image might be BGR instead of RGB :) and you miss this function here: glTexImage2D
[QUOTE=Pappschachtel;44483279]Are you sure you are loading your image right ? or sending it correctly to openGL ? your image might be BGR instead of RGB :) and you miss this function here: glTexImage2D[/QUOTE] Well the wood texture works fine as you can see in the picture, its just certain images :S the full source code is there at the link if you want to take a look. How do I use that glTexImage2d? Where does it go and what parameters does it take
kinda stuck on this one. decided to give Project Euler a try, and I'm already stuck at the first problem :v: the problem in question [quote]If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.[/quote] sounds easy enough, and I like to believe that I almost got it. [code]#include "stdafx.h" #include "iostream" using namespace std; int userInput() { cout << "Specify number you wish to double: " << endl; int x; cin >> x; return x; } int doubleNum(int z) { while (z <= 1000) { cout << z << endl; ++z; } return z; } int main() { int input = userInput(); doubleNum(input); } [/code] the problem I'm having is, as you might see, is that the value will increment only by 1 in the loop. no clue what I could do to make it multiply the original input by 2
why do you need to multiply the number? I might be misunderstanding the problem but it doesn't look like you have to. [editline]8th April 2014[/editline] i get that you have a method named doubleNum but that doesn't seem to have anything to do with the prompt
my approach is to multiply 3 or 5, output all the numbers inbetween, then use those numbers to figure out the sum of the multiples of 3 or 5 all the way to 1000 to be honest, I'm not sure if I understand the problem either. [editline]8th April 2014[/editline] ohh alright, the code isn't finished yet. I'd rather tackle one issue at the time rather than being overwhelmed by possibly more issues later in the code
[QUOTE=PredGD;44483462]my approach is to multiply 3 or 5, output all the numbers inbetween, then use those numbers to figure out the sum of the multiples of 3 or 5 all the way to 1000 to be honest, I'm not sure if I understand the problem either. [editline]8th April 2014[/editline] ohh alright, the code isn't finished yet. I'd rather tackle one issue at the time rather than being overwhelmed by possibly more issues later in the code[/QUOTE] Why don't you just loop until 1000 checking if it's divisible by 3 or 5 and if so add it to a total. [code] __inline bool IsDivisable(int val, int d) { return val % d == 0; } if ( IsDivisable(i,3) || IsDivisable(i,5) ) total += i; [/code] A even faster way would be to just directly calculate the sum with: (N(N + 1))/2
Okay I am having trouble with a project I'm thinking I could do for my audio production class. Basically what I originally thought of doing was doing all of my own custom sound design and SFX for the game Darksiders II. Now all the audio files are compiled in 3 separate .pck files filled with all the .wwise files that make up the game's sound. I can get into those files pretty easily but the biggest problem is it's really chaotic. There's no organization whatsoever, not even to their numbering. You'll play a file that's from the middle of the game, and then next file is from near the end of the game, etc. Now this is not something I really ever do so I have very little experience in any sort of scripting and complex files and whatnot. [IMG]http://screenshu.com/static/uploads/temporary/of/s0/yi/7phqpo.jpg[/IMG] Now I'm just gonna assume that this is all their own custom file formats and the only files I've been able to get into at this point are the game audio and dialogue. I was thinking maybe there would be something in any of these files that might point me where I need to go and what exact audio files I need to look at for certain instances such as [insert weapon]_swing_combo some shit like that. Basically, all I want to know is if this is even possible. Because even if I do go and painstakingly find each file I need to replace, I don't even know how to recompile .PCK files. I assume it's something you can script but hell if I know. If it's not worth the effort then just let me know and I'll move to something more plausible.
In OpenGL what is causing my wall to look like this when I enable lighting: [IMG]http://i.stack.imgur.com/grqqy.jpg[/IMG] Is it miscalculated normals?
Not sure if it will be much help but fuck it I'll post anyway, forgive me for being a complete novice. I'm trying to create a gradebook program in java for my class, and I'm running into a lot of problems. I'm supposed to split it up into individual methods and just call all the methods in the main. I have to prompt the user for 5 separate inputs, with the first name, last name, and three scores (all in one string of comma separated values). Output is supposed to look something like this: [IMG]http://i.imgur.com/D1OrAYP.png[/IMG] I feel like I might be going down the wrong path, can someone offer a little guidance or at least tell me if I'm headed the right direction? This is what I have so far: [CODE]import java.util.Scanner; public class GradebookJM { public static void main(String [] args) { // Inputs, constant, data declaration, initialization double sc1=0; double sc2=0; double sc3=0; double avg; String headerStr; String init; String id; String bday; String first, last; String c1, c2, c3, c4; int scMin; int scMax; userInput(); // Computations, algorithms avg = averageScore(sc1, sc2, sc3); // Outputs, formatting, display printHeader("Gradebook program prototype (PRGM14)"); printGrades(init, id, bday, sc1, sc2, sc3, scMin, scMax); } public static void userInput() { // Show the input dialog boxes Scanner input = new Scanner(System.in); String str; System.out.println("Please enter student last name, first name, and 3 whole-number test scores [0-100] in comma-separated value (CSV) format for student 1"); str = input.nextLine(); // Recieve the user input, parse it, and trim it int c1 = str.indexOf(",",0); int c2 = str.indexOf(",",c1+1); int c3 = str.indexOf(",",c2+1); int c4 = str.indexOf(",",c3+1); String last = str.substring(0,c1); String first = str.substring(c1+1,c2); String sc1 = str.substring(c2+1,c3); String sc2 = str.substring(c3+1,c4); String sc3 = str.substring(c4+1,str.length()); } public static void initials() { // Convert the first and last names into the student's initials } public static double averageScore(double sc1, double sc2, double sc3) { // Find the average of the three student scores double average = (double)(sc1 + sc2 + sc3) / 3; return average; } public static void printHeader(String headerStr) { // Print the header for the gradebook System.out.println(headerStr); System.out.println(" "); System.out.println("inits\t ID\t birthday\t sc1\t sc2\t sc3\t min\t max\t avg"); System.out.println("-----\t --\t --------\t ---\t ---\t ---\t ---\t ---\t ---"); } public static void printGrades(String init, String id, String bday, double sc1, double sc2, double sc3, int scMin, int scMax) { // Print the lines for each student System.out.println(init + "\t" + id + "\t" + bday + "\t" + sc1 + "\t" + sc2 + "\t" + sc3 + "\t" + scMin + "\t" + scMax); } }[/CODE] Whenever I compile I get a new set of errors, and I fix them and get different ones. Any help would be greatly appreciated.
Sorry, you need to Log In to post a reply to this thread.