Home » » 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

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);
     }

}



Share this article :

0 comments:

Post a Comment

 
Support : Creating | CollegeContents | Students work
Copyright © 2011. TestsInfo - All Rights Reserved
Created by Creativity Published by Leadership
Proudly powered by Vision