View Full Version : My Pker's Calculator {Made in visual basic}
my pker pure
July 7th, 2010, 19:23
I was bored, so i started on a new project of a calculator... It originally started out as a paint project like as in windows paint/drawing app but i decided to go for something a bit easier. (Hope you enjoy all download links are below)
Only the registered members can see the link.
Virus scan for anyone who thinks that its unsafe...
Only the registered members can see the link.
Calculator Only - Only the registered members can see the link.
All Files - Only the registered members can see the link.
Spear
July 7th, 2010, 19:28
Nice, I guess...
Fellixombc
July 7th, 2010, 20:28
Moved to the proper board...
Joshua F
July 7th, 2010, 20:50
Cept.. why make one, when Windows comes with a perfectly fine one?
Shishir G
July 7th, 2010, 20:53
Cept.. why make one, when Windows comes with a perfectly fine one?
dun be mean, i'm guessing he's still a beginner, so this is probably one of this new projects. It's a good start, nice job.
samuraiblood2
July 7th, 2010, 21:53
Instead of making buttons and a decently useless UI, you could've just parsed the input from the command line. Here's a simple calculator I just made in Java,
import java.util.Scanner;
public class CommandLineCalculator {
public static final String[] DELIMITERS = { "+", "-", "*", "/" };
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean doAgain = true;
do {
System.out.print("Problem: ");
String problem = in.nextLine();
String[] numbers = problem.split("\\s*[" + getDelimiter(problem) + "]\\s*");
if (numbers.length > 2) {
System.err.println("This program only supports simple problems.");
continue;
} else if (numbers.length < 2) {
System.err.println("You need at least two numbers in a problem.");
continue;
}
int first = 0;
int second = 0;
try {
first = Integer.parseInt(numbers[0]);
second = Integer.parseInt(numbers[1]);
} catch (NumberFormatException e) {
System.err.println("You must enter only numbers in place of values.");
continue;
}
int answer = 0;
if (getDelimiter(problem).equals("+")) {
answer = first + second;
} else if (getDelimiter(problem).equals("-")) {
answer = first - second;
} else if (getDelimiter(problem).equals("*")) {
answer = first * second;
} else if (getDelimiter(problem).equals("/")) {
answer = first / second;
}
System.out.println("Answer: " + answer);
System.out.print("Have another problem? (y/N) ");
doAgain = in.nextLine().equalsIgnoreCase("y");
} while (doAgain);
}
private static String getDelimiter(String problem) {
for (int i = 0; i < DELIMITERS.length; i++) {
if (problem.contains(DELIMITERS[i])) {
return DELIMITERS[i];
}
}
return null;
}
}
Programs output
Problem: 6*74
Answer: 444
Have another problem? (y/N) n
my pker pure
July 8th, 2010, 17:13
Thanks for the criticism but yeah i am new to this kind of programming so please dont flame
Mish
July 8th, 2010, 17:14
Awesome, goodjob :D
my pker pure
July 8th, 2010, 17:26
Awesome, goodjob :D
Thankyouu XD
Malik
July 8th, 2010, 18:28
Pretty cool, I would have no chance at making this myself ;)
my pker pure
July 8th, 2010, 18:41
New Project Is released - My Pker's Notepad - Only the registered members can see the link.
Trey
July 8th, 2010, 19:10
Cool. Now make one that parses infix to postfix using a stack and solves it, allowing for complex equations.
samuraiblood2
July 8th, 2010, 19:54
Cool. Now make one that parses infix to postfix using a stack and solves it, allowing for complex equations.
To much work, and I don't know enough about the postfix form.
my pker pure
July 8th, 2010, 20:17
I prefer to use visual basic it's abit more simple.
Trey
July 9th, 2010, 03:19
To much work, and I don't know enough about the postfix form.
Not as complex at it would seem, I prefer it over other methods of allowing equations like "(2 * (2 + (3 - 2))) * (8 + 2)" etc.
Pie`
July 9th, 2010, 17:04
This is below the beginner level. Realistically this is what, 2 lines of /actual/ code? The rest was just a simple drag & drop using the Visual Basic Studio IDE. He doesn't deserve recognition for this, he doesn't even deserve praise.
samuraiblood2
July 9th, 2010, 19:25
Not as complex at it would seem, I prefer it over other methods of allowing equations like "(2 * (2 + (3 - 2))) * (8 + 2)" etc.
But how would you handle equations like say, 55+5? In postfix that would turn to 555+ right?
Trey
July 9th, 2010, 22:13
But how would you handle equations like say, 55+5? In postfix that would turn to 555+ right?
That's why you insert spaces before and after all operators, and then parse it to postfix, ignoring solo spaces (in other words, if there already was a space before an operator now there will be 2, so we just ignore the second space). Any equation in postfix is solved in a single pass, which is why it is smart to convert infix to postfix so you can solve it in a single pass, since there is no order of operations in postfix.
samuraiblood2
July 9th, 2010, 23:08
That's why you insert spaces before and after all operators, and then parse it to postfix, ignoring solo spaces (in other words, if there already was a space before an operator now there will be 2, so we just ignore the second space). Any equation in postfix is solved in a single pass, which is why it is smart to convert infix to postfix so you can solve it in a single pass, since there is no order of operations in postfix.
Hmm, interesting, maybe ill mess around with it a little then. Is there a specific way to convert infix to postfix?
Trey
July 9th, 2010, 23:33
Hmm, interesting, maybe ill mess around with it a little then. Is there a specific way to convert infix to postfix?
Yup. I used these basic steps when I wrote a calculator a while ago. You'll have to tokenize your input rather than using a character by character method or else multiple digit numbers would be fucked. Precedence is order of operations.
Only the registered members can see the link.
Ramsin
July 9th, 2010, 23:37
EasEasy but nice... good for starter.
Sunni
July 10th, 2010, 02:02
Saw a tutorial on this on youtube, copied?
Skilled4u
July 10th, 2010, 06:37
sunni so what if he followed a tutorial? ... he's just learning...
my pker pure
July 10th, 2010, 11:16
I didn't even follow a tutorial ROFL
Sunni
July 10th, 2010, 15:18
sunni so what if he followed a tutorial? ... he's just learning...
Didn't mean it like that, don't try to be smart, I was just wondering.
admigo
July 17th, 2010, 23:06
i can make a more advanced calculator.
my pker pure
July 24th, 2010, 00:12
i can make a more advanced calculator.
Nobody cares what you can and can't do noob.
Charlie`
July 27th, 2010, 11:34
haha nice!
Powered by vBulletin® Version 4.1.9 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.