thrihyrne: Portland, OR (Starbuck by vilkibot)
Thrihyrne ([personal profile] thrihyrne) wrote2010-09-22 11:00 pm

My first java program

I wanted to weep. This is my first programming assignment. Cut because it's just code, and not even beautiful code at that, but it was the mathematics that made me want to tear out my hair.


import java.util.Scanner;
/**************************************
* Programming Assignment 1
*
* @author - Kristi Lee
* @version - V1 - 09//2010
*************************************/

/*************************************
* References and Acknowledgements:
*
*************************************/

public class ChangeMaker
{
/********************************************
* Change Maker is a program that converts an
* integer to the number of dollars, quarters,
* dimes, nickels and pennies.
********************************************/
public static void main (String args [])
{

// declarations
int input;
int dollar;
int modulusdollar;
int quarter;
int modulusquarter;
int dime;
int modulusdime;
int nickel;
int modulusnickel;
int penny;
int moduluspenny;



Scanner keyboard;

// input the seconds
keyboard = new Scanner(System.in);

System.out.print("Welcome to the Change Maker \n");

System.out.print("Enter the total amount of change:");
input = keyboard.nextInt();


dollar = input / 100;
modulusdollar = input % 100;
quarter = dollar / 25;
modulusquarter = modulusdollar % 25;
dime = quarter / 10;
modulusdime = modulusquarter % 10;
nickel = dime / 5;
modulusnickel = modulusdime % 5;
penny = nickel / 1;
moduluspenny = modulusnickel % 1;


System.out.print("Amount of change for $" + input + " is: \n");

System.out.print("\t Dollars:" + dollar + "\n");
System.out.print("\t Quarters:" + (modulusdollar / 25)) ;
System.out.print("\t Dimes:" + (modulusquarter / 10));
System.out.print("\t Nickels:" + (modulusdime / 5));
System.out.print("\t Pennies:" + (modulusnickel / 1));
}
}


I suck at this. But I think that syntax is my friend. It's the math that isn't.

:P

[identity profile] kymyrra.livejournal.com 2010-09-23 05:20 am (UTC)(link)
The computer languages, they are unforgiving masters. Can't tell you how many times i've banged my head in frustration at an error code caused by a missing semicolon. And i'm not even writing code, just modifying it. It will get easier for you, and there are tons of resources out there on the internets to help you when you get stuck.

[identity profile] thrihyrne.livejournal.com 2010-09-23 10:02 pm (UTC)(link)
When it works, it's great— but when it doesn't, augh. I tried submitting my program and it wasn't perfect enough. I'm glad I'm not taking the class for a grade because I doubt I'll be able to get a finished product polished enough to succeed the submission process.

[identity profile] eldritchhobbit.livejournal.com 2010-09-23 02:55 pm (UTC)(link)
I suspect you'll make friends with all of it before you're done. You're the gal who taught herself (and then me) HTML, don't forget! :)

*cheers you on*

[identity profile] thrihyrne.livejournal.com 2010-09-23 10:02 pm (UTC)(link)
That's true, but this seems so different… thank you for the supportive words!

[identity profile] gingerspark.livejournal.com 2010-09-23 06:18 pm (UTC)(link)
You'll do great!
you're already better than me at it! ;)

[identity profile] thrihyrne.livejournal.com 2010-09-23 10:03 pm (UTC)(link)
I don't know how I'll end up, but if nothing else, I'm learning the basics and I have a textbook that's checked out for 18 weeks, so I can continue on and teach myself if it comes to that.