Question

In: Computer Science

Write a Java program to compute the income after tax of an employee based on the...

  1. Write a Java program to compute the income after tax of an employee based on the following rule of tax rate. Assuming the salary is $22000, display the tax and the income after tax.

  • 12% if salary ≥ 25,000
  • 5% if salary < 10,000
  • Otherwise 8% will be applied

  1. Write a Java program to compute and display the sum of the numbers that can be both divisible by 6 and 8 from 1 to 500.

  1. Suppose there is a list of 15 integers: 38, 15, 29, 148, 72, 64, 116, 99, 284, 223, 117, 202, 63, 114, 96. Write a program that can i) display the even integers in ascending order and display their sum; ii) display the odd integers in ascending order and display their sum. (Hint: Use Arrays class to sort array items)

Solutions

Expert Solution

1Answer:

code:

import java.lang.*;
import java.util.*;
class Tax{
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter the amount : ");
       int amount = sc.nextInt();
       double tax, income;
       if(amount >= 25000){
           tax = (12 * amount) / 100.0;
       }else if(amount < 10000){
           tax = (5 * amount) / 100.0;
       }else{
           tax = (8 * amount) / 100.0;
       }
       System.out.println("Tax is : " + tax);
       System.out.println("Income is : " + (amount - tax));
   }
}

output:

2Answer:

code:

import java.lang.*;

import java.util.*;
class Sum{
   public static void main(String[] args){
       int sum = 0;
       int i;
       for(i=1;i<=500;i++){
           if((i % 6 == 0) && (i % 8 ==0)){
               sum = sum + i;
           }
       }
       System.out.println("The sum is : " + sum);
   }
}

output:

3Answer:

code:

import java.lang.*;
import java.util.*;
public class EvenOdd{
public static void main(String[] args){
int arr[] = new int[15];
int i, evenSum = 0, oddSum = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the array elements : ");
for(i=0;i<15;i++){
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
System.out.println("Even");
for(i=0;i<15;i++){
if(arr[i] % 2 == 0){
evenSum = evenSum + arr[i];
System.out.println(arr[i]);
}
}
   System.out.println("Even sum is : " + evenSum);
   System.out.println("odd");
    for(i=0;i<15;i++){
if(arr[i] % 2 != 0){
    oddSum = oddSum + arr[i];
System.out.println(arr[i]);
}
}
System.out.println("Odd sum is : " + oddSum);
}
}

output:


Related Solutions

write a java code Write a generic program to compute the sum of 30 terms of...
write a java code Write a generic program to compute the sum of 30 terms of the following series. (181 - 5)/31 + (186 + 9)/34 - (191 - 13)/37 + (196 + 17)/40 + . . . . . 1 5 11 Note: the 3rd, 6th, 9th term etc, has a negative sign in front of parenthesis. User Input: None Expected output: Term Ratio Sum 1 5.677 5.677 2 5.735 11.413 3 -4.811 6.602
Java Programming: Write a program that allows the user to compute the power of a number...
Java Programming: Write a program that allows the user to compute the power of a number or the product of two numbers. Your program should prompt the user for the following information: • Type of operation to perform • Two numbers (the arguments) for the operation to perform The program then outputs the following information: • The result of the mathematical operation selected. Menu to be displayed for the user: MATH TOOL 1. Compute the power of a number 2....
Write a program that determines the income tax rates for a state. Tax rates are based on the salary according to the following table:
in java  Code Problem 2 Write a program that determines the income tax rates for a state.  Tax rates are based on the salary according to the following table: 0 – 25000 Dollars                    10% 25001 - 50000 Dollars            15% 50001 - 75000 Dollars             20% Over 75000 Dollars                 35% Write the program so that it asks the user how many taxpayers should be processed and use the number of taxpayers to control the end of the program. For each taxpayer, you will need to input the...
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1....
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods you...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps:...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods...
Based on the amounts of taxable income below, compute the federal income tax payable in 2018...
Based on the amounts of taxable income below, compute the federal income tax payable in 2018 on each amount assuming the taxpayers are married filing a joint return. Also, for each amount of taxable income, compute the average tax rate and the marginal tax rate. a. Taxable income of $30,000 b. Taxable income of $100,000 c. Taxable income of $375,000 d. Taxable income of $700,000
Based on the amounts of taxable income​ provided, compute the federal income tax payable in 2017...
Based on the amounts of taxable income​ provided, compute the federal income tax payable in 2017 on each amount assuming the taxpayers are married filing a joint return.​ Also, for each amount of taxable​ income, compute the average tax rate and the marginal tax rate. Taxable income of $50,000. . Taxable income of $125,000. . Taxable income of $380,000. . Taxable income of $510,000
write a java code program using loops to compute the sum of the 30 terms of...
write a java code program using loops to compute the sum of the 30 terms of the series below. Find sum of all integers between 100 and 200 which are divisible by 9 or 13 Write a program to find the sum of the first 8 terms of the series 1 + 11 + 111 + 1111 + . . . Output: Term Ratio Sum
JAVA 5- Write a program that prompts the user to enter two (2) numbers and compute...
JAVA 5- Write a program that prompts the user to enter two (2) numbers and compute the sum of the numbers between these two numbers (including the numbers entered). If the user Enters 2 and 6. The program will calculate the sum of the numbers: 2+3+4+5+6 and will display the result. Enter First number> 2 Enter second number> 6 The sum is 20
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final...
Create a Project and a Class called “FinalGrade” Write a Java program to compute your final grade for the course. Assume the following (you can hard-code these values in your program). Assignments are worth 30% Labs are worth 40% Mid-term is worth 15% Final is worth 15% Ask for the grades in each category. Store them in a double variable. Print out the final percentage grade.           For example, Final Grade Calculation Enter percentage grades in the following order. Assignments,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT