|
Create a Java program that prompts the user
for the year they were born in and prints out their current age.
|
|
import
java.util.Calendar;
public class YourAge
{
public static void
main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please enter the year of
your birth");
Calendar now = Calendar.getInstance();
int year =
scan.nextInt();
int age =
now.get(now.YEAR) - year;
System.out.println ("Your age is " + age );
scan.close();
}
}
|
|
Write a Java program that asks the user for
the user's annual salary (e.g $250,000). Print out the following based on the
user's salary. 1. Social security tax (7% of the salary) 2. Federal tax (20%
of the salary) 3. State tax (10% of the salary) 4. Tax return (30% of the
total paid taxes) 5. Annual income after taxes (includes the tax return)
Partial credit is given but the standards are much higher for the extra
credit problems
|
|
import
javax.swing.*;
public class
AnnualSalary
{
public static void
main(String[] args)
{
String salary = JOptionPane.showInputDialog("Please
enter your total income ");
//String salary =
"250000";
int i =
Integer.parseInt(salary);
double
socialSecurity = Double.parseDouble(salary) * .07;
double
federalTax = Double.parseDouble(salary) * .2;
double stateTax
= Double.parseDouble(salary) * .1;
double totalTax
= socialSecurity + federalTax + stateTax;
double afterTax
= i - totalTax;
double taxReturn
= totalTax * .3;
double
totalIncome = afterTax + taxReturn;
//System.out.println("Your
total annual income is = $ " + totalIncome);
JOptionPane.showMessageDialog(null, "Your
total annual income is = $ " + totalIncome);
}
}
|
Home »
java
» Create program to display your current age; Write a Java program that asks the user for the user's annual salary.
Create program to display your current age; Write a Java program that asks the user for the user's annual salary.
Written By Unknown on Tuesday, October 8, 2013 | 10:55 AM
Labels:
java
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment