In: Computer Science
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: