I'm also learning Java atm. I think after getting hang of a little bit of delphi everything just kinda falls itself into place.
Equals method in the string class?
you mean like:
If ('stringVar1' = 'stringVar2'){
//Stuff
}
?
dont forget to convert variable so they match when you are using the if statements!
Here's my assignment programs (yeah for school, take it as a helper if you need :)) - Done with Ready to Program.
import java.applet.*; // some of the nessisary inports
import java.awt.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class FedTax
{
public static void EndingComment (String name, double salary, double tax, double result) throws IOException
{ // This is my method, used to shorten the code & for learning.
// Has all the final output statements bundled together
System.out.println ("");
System.out.println (name + ", your annual salary will have a federal tax rate of " + (tax * 100) + "%");// tax rate output
System.out.println (name + ", you will be taxed " + result + " dollars for your annual salary");// amount deducted from income
System.out.println (name + ", your annual salary after tax will be " + (salary - result)); // salary after tax
}
public static void main (String[] args) throws IOException // main method
{
// initializes the buffered reader for keyboard input detection
InputStreamReader inStream;
BufferedReader keyboard;
inStream = new InputStreamReader (System.in);
keyboard = new BufferedReader (inStream);
//My variables
String sResult, name, sSalary;
double tax, result, salary;
// The main menu for the user with al the rates & basic calculating info
System.out.println ("The Calculator For Federal Tax");
System.out.println ("-----------------------------");
System.out.println ("---The Tax Reference Chart---");
System.out.println ("-----------------------------");
System.out.println ("Annual Salary Federal Tax Rate");
System.out.println ("$0 - $10 000 0%");
System.out.println ("$10 001 - $25 000 20%");
System.out.println ("$25 001 - $50 000 25%");
System.out.println ("$50 001 - $100 000 25%");
System.out.println ("$100 000 + 35%");
System.out.println ("------------------------------");
System.out.println ("Ur name plz");// asks & gets name
name = keyboard.readLine ();
System.out.println ("Ur annual salary plz (If you do words, i'm not calculating for u)");// asks and gets salary
sSalary = keyboard.readLine ();
salary = Double.parseDouble (sSalary);
if (salary > 100000)// if salary is more than 100000
{
tax = 0.35; //35% tax
result = ((salary - 100000) * tax - 3000 - 6250 - 9000);// calculates amount of tax paid
EndingComment (name, salary, tax, result);
}
else if (salary < 10001)// if salary is less than 10000
{
tax = 0;// no tax
result = 0;// no calculation cuz no tax
EndingComment (name, salary, tax, result);
System.exit (0);
}
else if (salary > 10000)
{
if (salary < 25001)// if salary is more than 10000 & less than 25001
{
tax = 0.20;// 20% tax
result = ((salary - 15000) * tax);// calculates amount of tax paid
EndingComment (name, salary, tax, result);
}
}
else if (salary > 25000)
{
if (salary < 50001)// if salary is more than 25000 & less than 50001
{
tax = 0.25;// 25% tax
result = ((salary - 25000) * tax - 3000);// calculates amount of tax paid
EndingComment (name, salary, tax, result);
}
}
else if (salary > 50000)
{
if (salary < 100001)// if salary is more than 50000 & less than 100000
{
tax = 0.3;// 30% tax
result = ((salary - 50000) * tax - 3000 - 6250);// calculates amount of tax paid
EndingComment (name, salary, tax, result);
}
}
}
}