This isn't really a question about programming...it's a question of preference...
when it comes to programming, what do you prefer?
Mine is Java...so simple...so...simple...

simple? Ok make me a program where I type in an ammount of money and it calculates tax. Then I input the tendered amount and it calculates the exact ammount of change i get from a penny to a fifty dollar bill then outputs a receipt...
Do that and send me the source in notepad and we'll see how good you really are.
At 10/28/04 10:37 PM, kyle_chamberlain wrote: Do that and send me the source in notepad and we'll see how good you really are.
Come on! That is simple.
Lemme guess, you have a program like that due for school.
What may man within him hide, though angel on the outward side.
At 10/28/04 10:37 PM, kyle_chamberlain wrote: simple? Ok make me a program where I type in an ammount of money and it calculates tax. Then I input the tendered amount and it calculates the exact ammount of change i get from a penny to a fifty dollar bill then outputs a receipt...
Heh, what's the amount of taxation? Here in NJ, it's 6%...
Yay fun.
import java.io.*;
public class MuthaFuckinTaxator{
public static void main(String[] args) throws IOException{
double theTax = .06;
InputStreamReader isr = new InputStreamReader( System.in );
BufferedReader stdin = new BufferedReader( isr );
System.out.print("Cost of item: ");
String input = stdin.readLine();
double cost = Double.parseDouble(input);
cost += cost * theTax;
cost = (int)Math.round(cost*100.0);
System.out.print("You're paying: ");
String input2 = stdin.readLine();
double money = Double.parseDouble(input2);
money = (int)Math.round(money * 100.0);
if(cost > money){
System.out.println("You didn't pay enough. Get a job, you hobo!");
}else{
double change = money - cost;
int fifties=0, twenties=0, tens=0, fives=0, singles=0, quarters=0, dimes=0, nickels=0, pennies=0;
for(int i=0;change>0;i++){
if(change>=5000){
fifties++;
change -= 5000;
}else if(change>=2000){
twenties++;
change -= 2000;
}else if(change>=1000){
tens++;
change -= 1000;
}else if(change>=500){
fives++;
change -= 500;
}else if(change>=100){
singles++;
change -= 100;
}else if(change>=25){
quarters++;
change -= 25;
}else if(change>=10){
dimes++;
change -= 10;
}else if(change>=5){
nickels++;
change -= 5;
}else if(change>=1){
pennies++;
change -= 1;
}else{
break;
}
}
System.out.println();
System.out.println("############################################");
System.out.println("Your Change:\n-----------");
System.out.println("Fifties: " + fifties);
System.out.println("Twenties: " + twenties);
System.out.println("Tens: " + tens);
System.out.println("Fives: " + fives);
System.out.println("Singles: " + singles);
System.out.println("Quarters: " + quarters);
System.out.println("Dimes: " + dimes);
System.out.println("Nickels: " + nickels);
System.out.println("Pennies: " + pennies);
System.out.println("############################################");
System.out.println();
}
}
}
I'm taking java now, hence the n00bishness of this script. I would have made a nifty class but I was in a hurry and needed a 'lil practice in Java. I did this in school, just modified it a bit for this.
At 10/28/04 11:43 PM, -BurstFilms- wrote: I'm taking java now, hence the n00bishness of this script. I would have made a nifty class but I was in a hurry and needed a 'lil practice in Java. I did this in school, just modified it a bit for this.
Holy Shit!!! Damn I thought Java was pretty damn hard!!! Anyway, If you know anything about java3d i would be really interrested. I tried learning it but all attempts were failed. It's like 20 lines of script for one object and it probably compiles down to a byte of info lol. I still never did learn how to make a cube... The tutorial taught me pyramids, cylinders, spheres, gears, custom meshes, and a 1 by 1 generic colored cube that supports no customability, but NO REGULAR CUBE.
Anywho, i would love to learn java sometime. You know - like the graphics-intense stuff like open-GL and java3D... not some petty form where you input taxes and crap lol...
I know what you're thinking, though... Flash! True, but I want something in real-time 3d (java3d) and with the ability to be used online (an example of what i mean would be something like runescape, but doesn't really have to be that graphics intense). Java can create and edit and view files, while all Flash can do is view them. Not at all good for online games. However, I have seen countless flash with high-score lists. I have NO idea how they do that, but if you know i would to learn.
Whew, thats a lot of typing... I AM going to compile and test that class you made, though.
This is similar to the Roman umeral converter program. You should use a method for determining the amount needed, rather than sticking it all in the main. But you're just starting so w/e.. Good job
something like this:
/*this method returns an array of values which represent how many of each denomination of bill/coin represents a given amount (example 23.46 returns double [] {0,1,0,0,1,1,1,2,1}, or one twenty, a toonie, a loonie, a quarter, two dimes and a penny.*/
public static double[] getCoin (double amount) { // Canadian, srry :)
double [] cur = new double [] { 50,20,10,5,2,1,0.25,0.1,0.05,0.01};
int [] values = new int [10] ; // for each bill/coin
for (int i = 0; i < 10; i++) { // note you could use a var instead of 10
values[i] = 0; // init all values to zero
while (amount>cur[i] {
amount -= cur[i]; // should be a minus/equals; shitty html
values[i]++; // keep track of how many of each bill.
} //end while
} //end for
return values;
}// end getCoin
you could cut and paste this and it should work. However, you need to call it properly from the main method.
Nice work guys. Now to answer the actual post. There is no language that is always preferred over another. The best language to use depends on what you want to program and where you run that program. Each language has its own strengths/weaknesses that make it more appropriate for different tasks. For example, C++ is optimized for windows. So if I write a program in C++ and then write the same program in Java and run them both on windows the program in C++ will run faster. However, if I take my programs and run them on a linux the C++ program will probably crash whereas the Java program will work, since Java is more flexible than C++ and works the same on all operating systems. So the answer is no. There is no special preference.