Hey All,
I received another question from one of my readers concerning basic Java. While I love to help, questions have been flooding in about Java and not much else! I have a good bit of experience with Database Management, All things Networking, Data Mining, and much more so feel free to ask pretty much anything IT related! I made a video for everyone so its easier to follow along!
My name is Paul Welch and I am pursuing a BSBA degree from Auburn University with a major in Management Information Systems. This blog will document my thoughts, ideas, and overall progress as I venture into the vast world of Information Technology.
Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Thursday, February 17, 2011
Validating Input in Java
Labels:
IT help,
Java,
Java Help,
Java Homework,
Java Validation,
Validate Data
Monday, February 14, 2011
Create a multiplication Table in Java (with user input)
I received a question from a reader that asked how to create a basic Multiplication table in Java with user defined limits. I made a video for this! Enjoy
Wednesday, February 9, 2011
Java Programming - There are only 10 kinds of people in this world: those who know binary and those who don’t.
While I am sitting at home working on some Java Applets for my advanced programming class, I got to wondering how useful this language will be in the real world. I know it is used widely for creating basic standalone applications and internet applets, but some fellow MIS majors stress that it is one of the lesser used languages in the programming world - however that once you learn a language such as java that it becomes MUCH easier to learn other languages. I have heard that C++ is very versatile and not too bad to learn. Assembly seems to be the toughest, and I just began looking into languages such as Python and Ruby on Rails.
EncyclopediaDramatica, a satirical wiki that documents internet culture (and pretty much makes fun of everything) defines Java as
One thing I have realized is how much work one can put into Java, and how confusing it must look to the untrained eye. For example, I built a program below that makes a multiplication table up to the number that the user inputs:
What do y'all think about Java and other languages? Feel free to comment
EncyclopediaDramatica, a satirical wiki that documents internet culture (and pretty much makes fun of everything) defines Java as
Java is an interpreted language which is unique in that it includes a pretend compiler so that Java programmers can feel like they're using a grownup programming language. It is object oriented and has automatic garbage collection to make it as easy as possible to allocate memory.Java is like Alzheimers; it starts slow and eventually, it takes away all of your memory. Something Java fans like to talk about is the JIT compiler which eventually does turn Java into native code but only after it's been interpreted 10,000 times. By that time the program has probably already crashed with an out of memory error. Programming in Java drives most hackers permanently insane.
One thing I have realized is how much work one can put into Java, and how confusing it must look to the untrained eye. For example, I built a program below that makes a multiplication table up to the number that the user inputs:
import javax.swing.*;public class pw {
public static void main(String[] args) {
String matrixSize = JOptionPane.showInputDialog("Welcome to the Paul Welch multiplication table. What number would you like to multiply through?");int userMatrixSize = Integer.parseInt(matrixSize);
int column;
This is a program I built to build an employee payroll and report system. It took a great while, a lot of code memorization, patience, and correct syntax. It gathers the employees information, calculates taxes, and provides a monthly/yearly report.System.out.println("Multiplication Table through " + userMatrixSize);
for (row=1; row<=userMatrixSize; row++) {for (column=1;column<=userMatrixSize; column++) {System.out.print(" " + row*column + " ");System.out.println(" ");}System.out.println( " Thank you for using the Paul Welch Multiplcation Table " );
I suppose it makes me appreciate that most code for basic functions are stored in an API and what not, and I also appreciate the programmers who spent tedious hours writing it.
public class pwEmployeePayroll{public static void main(String args[]){ // declare varsString hrWage;String hoursWeek;String dedPer;String howManyYear;String employeeName;double hourlyWage=0.00;double hoursPerWeek=0.00;double deductionPaycheck=0.00;double lessThanTwenty = .10;double betTwenThir= .15;double greatThir= .19;double totalPaid=0.00;double totalPaidPreTax=0.00;double totalTaxesPaid = 0.00;double paycheckAmount=0.00;String monReport;int monthsReport = 0;double x = 20.00;double y = 30.00;String howManyMonths;// introSystem.out.println("Welcome to the Paul Welch Tax Calculator." );System.out.println(" This program will gather information from you and calculate relevant items, such as taxes.");System.out.println("Lets gather some information about the employee on which you seek information!");System.out.println(" Note : please enter all numbers in a whole number form, i.e. 30.00");// get user infoemployeeName= JOptionPane.showInputDialog( " What is the employees name?");hoursWeek=JOptionPane.showInputDialog(" How many hours does the employee work a week ");hoursPerWeek = Double.parseDouble(hoursWeek);while ( hoursPerWeek <=0 ){System.out.println(" Invalid Entry. Try again");hoursPerWeek = Double.parseDouble(JOptionPane.showInputDialog( " What is the employees hours per week?"));} // Validate entryhrWage=JOptionPane.showInputDialog( " What is the employees hourly wage");hourlyWage= Double.parseDouble(hrWage);while (hourlyWage <=0){System.out.println("Invalid Entry. Please enter again");hourlyWage = Double.parseDouble(JOptionPane.showInputDialog(" What is the employees hourly wage"));} // Validate entrytotalPaidPreTax = hoursPerWeek * hourlyWage;//Calculations : figure out total taxes paid and what notif (hourlyWage < x || hourlyWage != 0){totalTaxesPaid = (totalPaidPreTax * lessThanTwenty);}if (hourlyWage >= x && hourlyWage <= y){totalTaxesPaid = (totalPaidPreTax * betTwenThir);}if (hourlyWage > y){totalTaxesPaid = (totalPaidPreTax * greatThir);}paycheckAmount = (totalPaidPreTax - totalTaxesPaid); System.out.println(" Per month, the employee's information is as follows:");System.out.println("Employee Name " + employeeName);System.out.println("Paycheck amount " + paycheckAmount);System.out.println("Total taxes paid " + totalTaxesPaid);System.out.println( "Total paid pre-tax " + totalPaidPreTax );// Basic information is set and stored, now onto calculating over time periodsmonReport =JOptionPane.showInputDialog( "Would you like to calculate that with additional months? Please enter Y or N");while ((monReport.compareTo("Y") !=0) && (monReport.compareTo("N") !=0)){System.out.println("Invalid Response. Please enter Y or N");} // Validate entry
while(monReport.equals("Y")){howManyMonths = JOptionPane.showInputDialog("How many months would you like to calculate");// Input, then calculatemonthsReport = Integer.parseInt(howManyMonths);paycheckAmount = paycheckAmount * monthsReport;totalPaidPreTax = totalPaidPreTax * monthsReport;totalTaxesPaid = totalTaxesPaid * monthsReport;System.out.println( "For that amount of months, the employee's pay and taxes is as follows");System.out.println("Employee Name " + employeeName);System.out.println("Paycheck amount " + paycheckAmount);System.out.println("Total taxes paid " + totalTaxesPaid);System.out.println( "Total paid pre-tax " + totalPaidPreTax);String yearlyReport=JOptionPane.showInputDialog("Would you like a yearly report on this employee? Enter Y for yes or N for no");while(yearlyReport.equals("Y")){howManyYear= JOptionPane.showInputDialog(" How many years would you like to calculate?");int howManyYears = Integer.parseInt(howManyYear);System.out.println("Yearly report is as follows:");paycheckAmount = paycheckAmount * howManyYears;totalPaidPreTax = totalPaidPreTax * howManyYears;totalTaxesPaid = totalTaxesPaid * howManyYears;System.out.println("Employee Name " + employeeName);System.out.println("Paycheck amount " + paycheckAmount);System.out.println("Total taxes paid " + totalTaxesPaid);System.out.println( "Total paid pre-tax " + totalPaidPreTax);while((yearlyReport.compareTo("Y") !=0) && (yearlyReport.compareTo("N") !=0))System.out.println("Invalid Response. Please enter Y or N");yearlyReport =JOptionPane.showInputDialog(" Would you like another yearly report on this employee? Enter Y for yes or N to quit the program");}
What do y'all think about Java and other languages? Feel free to comment
Subscribe to:
Posts (Atom)