Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
Basic JAVA ~easy to understand~
here is some codes in java, this is the first part of two parts. also check out these programs in cpp, cobol and also c# and vb.net. i will be posting… please replay if this is help ful.
I USED A PROGRAM CALLED ECLIPSE TO DO THEM. DOWNLOAD IT FOR FREE. IT's COOL TOO!!!
public class ass1 {
public static void main( String args[] )
{
double AmountoPay;
double NumberoPeriod;
double total;
AmountoPay =1700.00;
NumberoPeriod = 26;
System.out.print("Amount of pay per pay period is $");
System.out.print(AmountoPay);
System.out.print("\n");
System.out.print("\nNumber of pay periods per year is ");
System.out.print(NumberoPeriod);
System.out.print("\n");
total = AmountoPay * NumberoPeriod;
System.out.print("\nThe annual pay is $");
System.out.print(total);
System.out.print("\n");
System.out.print("\n");
System.exit( 0 );
}
}
public class ass2 {
public static void main( String args[] )
{ double perc = .62;
int Tsale = 4600000;
double PredSal;
PredSal = perc * Tsale;
System.out.print("Predicted East Coast Sales = $");
System.out.print(PredSal);
System.out.print("\n");
System.out.print("\n");
System.exit( 0 );
}
}
import javax.swing.JOptionPane;
public class ass3 {
public static void main( String args[] )
{
String input;
String result;
int total1,total2, total3;
input = JOptionPane.showInputDialog( "Enter number 1:" );
total1 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter number 2:" );
total2 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter number 3:" );
total3 = Integer.parseInt( input );
result = "THe total Avg. is " + ( (total1 + total2 + total3)/3 );
JOptionPane.showMessageDialog( null, result, "Calculation Results",
JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 ); // terminate application
}
}
public class ass3 {
public static void main( String args[] )
{
double PurchasePrice; //purchase price
double CountySaletTax; //country sale tax
double StateSalestax; //state sales tax
double TotalSaleTax; //total sale tax
PurchasePrice =52;
CountySaletTax =PurchasePrice * .02;
StateSalestax =PurchasePrice * .04;
TotalSaleTax =CountySaletTax + StateSalestax;
System.out.print("On a purchase of $");
System.out.print(PurchasePrice);
System.out.print("\n");
System.out.print("\n");
System.out.print("The county sales tax = $");
System.out.print(CountySaletTax);
System.out.print("\n");
System.out.print("\n");
System.out.print("The county sales tax = $");
System.out.print(StateSalestax);
System.out.print("\n");
System.out.print("\n");
System.out.print("the total sale tax = $");
System.out.print(TotalSaleTax);
System.out.print("\n");
System.out.print("\n");
System.exit( 0 );
}
}
import javax.swing.JOptionPane;
public class ass5 {
public static void main( String args[] )
{
String input;
String result;
int total;
input = JOptionPane.showInputDialog( "Emter meal amount:" );
total = Integer.parseInt( input );
result = "The total includes 15% tip and tax,The Total is " +(total+ (total * .0675)+ (total *.15));
JOptionPane.showMessageDialog( null, result, "Calculation Results",
JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 ); // terminate application
}
}
import javax.swing.JOptionPane;
public class ass6 {
public static void main( String args[] )
{
String input;
String result;
String sub;
String all;
int total1,total2, total3, total4, total5;
double tax = .06;
input = JOptionPane.showInputDialog( "Enter amount 1:" );
total1 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter amount 2:" );
total2 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter amount 3:" );
total3 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter amount 4:" );
total4 = Integer.parseInt( input );
input = JOptionPane.showInputDialog( "Enter amount 5:" );
total5 = Integer.parseInt( input );
int totals=(total1 + total2 + total3 +total4+total5 );
double totaltax=(tax*(total1 + total2 + total3 +total4+total5 ));
result = "The amount total is: " + totals;
sub = "The total tax is: " + totaltax;
all = "The Grand total is: " + (totals+totaltax);
JOptionPane.showMessageDialog( null, result, "Calculation Results",
JOptionPane.INFORMATION_MESSAGE );
JOptionPane.showMessageDialog( null, sub, "Calculation Results",
JOptionPane.INFORMATION_MESSAGE );
JOptionPane.showMessageDialog( null, all, "Calculation Results",
JOptionPane.INFORMATION_MESSAGE );
System.exit( 0 ); // terminate application
}
}
You can use System.out.println instead of putting a /n at the beginning of every new statement.
Oh, and you can use the concantenation symbol (+) to put some things together. For example, you have:
System.out.print(StateSalestax);```
which could be rewritten as:
```markupSystem.out.print("The county sales tax = $" + StateSalestax);```
which effectively eliminates a line of code.
I'm still learning Java, so those are the only things I noticed. Hope I helped and didn't confuse anyone too much.