Wednesday, 19 December 2018

lab 10


1.
import java.util.Scanner;

public class Test1{

     public static void main(String []args){
     
        Scanner input = new Scanner(System.in);
        double[] student1Scores = new double[4];
     
System.out.println("How many students do you want to record?");
int noOfStudents = input.nextInt();

String[] names = createNames(noOfStudents);

System.out.println("Please enter their scores:");
         for(int i=0;i<names.length;i++)
{
System.out.println("Enter score for " + names[i]);
            for(int j=0;j<student1Scores.length;j++)
            {
                student1Scores[j] = input.nextDouble();
            }
            double average = averageScore(student1Scores);
System.out.println(names[i] + " average score is " + average);
char grade = determineGrade(average);
System.out.println(names[i] + " grade is then " + grade);
        }
System.out.println("Displaying all names!");
displayNames(names);
        }

public static String[] createNames(int noOfStudents)
{
String[] n = new String[noOfStudents];

Scanner input = new Scanner(System.in);
System.out.println("Please enter " + noOfStudents  + " student's names");
        for(int i=0;i<n.length;i++)
        {
            n[i] = input.nextLine();
        }
System.out.println("You have entered all names!TQ");
return n;
}

public static void displayNames(String[] names)
{
for(int i=0;i<names.length;i++)
{
System.out.println(names[i]);
}
}
 
     public static char determineGrade(double average)
{
if(average > 90)
return 'A';
else if(average > 80)
return 'B';
else return 'C';
}

     public static double averageScore(double[] x)
     {
     
         double sum = 0;
         for(int i=0; i<x.length;i++)
         {
             sum = sum + x[i];
         }
         double average = sum/x.length;
         return average;
     }


}



2.
import java.util.Scanner;
public class Test2{
public static void main (String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter number of rows and column of array:");
int rows = input.nextInt();
int columns=input.nextInt();
double [][]table=new double[rows][columns];
System.out.println("Enter array:");
for(int i=0;i<table.length;i++)
{
for(int j=0;j<table[i].length;j++)
{
table[i][j]=input.nextDouble();
}
}
int[] location=locateLargest(table);
System.out.printf("The location of the largest element is (%d,%d)%n",location[0],location[1]);
}

public static int []  locateLargest(double[][]a)
{
int [] location=new int [] {0,0};
double largest=a[0][0];
for (int i=0;i<a.length;i++)
{
for(int j=0;j<a[i].length;j++)
{
if(largest<a[i][j])
{
largest=a[i][j];
location[0]=i;
location[1]=j;
}
}

}
return location;
}
}








3.
import java.util.Scanner;
public class Test3{

     public static void main(String []args){
         final int Total_numbers=6;
         int[] numbers = new int[Total_numbers];
         Scanner input=new Scanner (System.in);
        System.out.println("Enter" + number.length + "integer numbers: ");
        //Read all numbers
        for (int i=0;i<numbers.length;i++)
        {
            number[i]=input.nextInt();
        }
        //find the largest element
        int max=numbers[0];
        for (int i=1;i<numbers.length;i++)
        {
            if (numbers[i]>max)
            {
                max=numbers[i];
            }
        }
        //find the smallest element
        int min=number[0];
        for (int j=1;j<numbers.length;j++)
        {
            if (numbers[j]<min)
            {
                min=numbers[j];
            }
        }
        //find the occurence of the largest number
        int count1=0;
        for(inti=0; i<numbers.length;i++)
        {
            if(numbers[i]==max)
            count1++;
        }
        //find the occurence of the smallest number
        int count2=0;
        for(int j=0;j<numbers.length;j++)
        {
            if(numbers[j]==min)
            count2++;
        }
        int swap=numbers[0];
        for(int i=0; i<numbers.length/2;i++)
        {
            int temp=numbers[i];
            numbers[i]=numbers[numbers.length-i-1];
            numbers[numbers.length-i-1]=temp;
        }
        //prepare the result
        System.out.println("Output:");
        System.out.println("The array is:");
        for (int i=0; i<numbers.length;i++)
        {
            System.out.println(numbers[i] + "");
         
            System.out.println();
            System.out.println("The largest number is " + max);
            System.out.println("The smallest number is" + min);
            System.out.println("The occurrence count of the largest number is" + count1);
            System.out.println("The occurence count of the smallest number is" + count2);
         
         
        }
    }
     
 }
}



4.
import java.util.Scanner;
public class Test4 {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
final int maxrange=10;
final int minrange =-1;
final int range=10;

int[] list=new int[maxrange];

for(int i=0; i<list.length;i++)
{
list[i]=0;
}
System.out.println("Enter a list of integer between 1 and 100");
System.out.println(" To stop, enter an integer not in this range");
System.out.println("Enter integer");
int value= input.nextInt();
while (value>=minrange && value<=(maxrange*range))
{
list[(value-1)/range]=list[(value-1)/range]+1;
System.out.println("Enter integer");
value=input.nextInt();
}
System.out.println("Here is your histogram");
for (int i=0;i<list.length;i++)
{
System.out.println(" " + (i*range+1) + " " + (i+1)*range+ "\t|");
for (int j=0; j<list[i];j++)
{
System.out.println("*");
}
System.out.println();
}
}
}



Lab 9

1.
a. Create an array to hold 10 double values.
double[] list = new double[10];
b. Assign the value 5.5 to the last element in the array.
 list[list.length - 1] = 5.5;
c. Display the sum of the first two elements. 
System.out.println(list[0] + list[1]);
d. Write a loop that computes the sum of all elements in the array. 
double sum = 0;
                       for (int i = 0; i < list.length; i++)
                                   sum += list[i];
e. Write a loop that finds the minimum element in the array.
double min = list[0];
                       for (int i = 1; i < list.length; i++)
                                   if (min > list[i])  min = list[i];
f. Randomly generate an index and display the element of this index in the array.
System.out.println(list[(int)(Math.random() * list.length)]);
g. Use an array initializer to create another array with the initial values 3.5, 5.5, 4.52 and 5.6.
double[] list = {3.5, 5.5, 4.52, 5.6};

2.
public class Test{

     public static void main(String []args){
         double[] r= new double[100];
         for (int i = 0; i < r.length; i++)
         {
         r[i] = (int)(Math.random() * r.length);
         }
        System.out.println(r[1]);
     }

}





3.

import java.util.Scanner;
public class karyeeTest3{

     public static void main(String []args){
         int n, temp;
         Scanner input = new Scanner(System.in);
         System.out.println("Enter number of array");
         n= input.nextInt();
         int values[]=new int[n];
         System.out.println("Enter all the values");
         for (int i = 0; i < n; i++)
         {
            values[i]=input.nextInt();
         }
         for (int i=0;i<n;i++)
         {
             for(int j=i;j<n;j++)
             {
                 if(values[i]>values [j])
                 {
                     temp=values[i];
                     values[i]=values[j];
                     values[j]=temp;
                     
                 }
             }
         }
        System.out.println("increasing order");
        for (int i=0; i<n; i++)
        {
            System.out.println(values[i]);
        }
     }

}





4.
import java.util.Scanner;
public class Test4{

     public static void main(String []args){
         int n;
         int temp = 0;
         Scanner input = new Scanner(System.in);
         System.out.println("Enter number of array");
         n= input.nextInt();
         int[] values=new int[n];
         int[] count=new int[n];
         for (int i = 0; i < values.length; i++)
         {
            values[i]= (int)((Math.random() *9) +1);
         }
         System.out.print("Values are");
         for (int i=0;i<values.length;i++)
         {
             System.out.print(values[i] + "");
         }
        for(int i=0; i<values.length;i++)
                 {
                   temp=values[i];
                   for (int j=0; i<values.length;i++)
                   {
                       if(temp==values[j])
                       {
                           count[i]++;
                       }
                   }
                 }

    System.out.println();
    for (int i=0;i<count.length;i++)
    {
        if(count[i]>1)
        {
            System.out.println(values[i]+ "occurs" + count[i] + "times");
         }
else
            {
                System.out.println(values[i] + "occurs" + count[i] + "time");
            }
    }
     }

}


5.


import java.util.Scanner;
public class karyeeTest5{

     public static void main(String []args){
    int[] score=new int[100];
    int sum=0;
    int num=0;
    int numOfScores;
    double average= numOfScores=0;
    Scanner input= new Scanner(System.in);
    System.out.println("Enter score(Negative number signifies end):");
    for (int i=0; i<score.length; i++)
    {
        score[i]=input.nextInt();
        if (score[i] <0)
        break;
        sum+= score[i];
        num++;
    }
    average =sum/sum;
    int aboveOrEqual;
    int below;
    aboveOrEqual=below=0;
    for(int i=0; i< num;i++)
    {
        if(score[i]>=average)
        {
            aboveOrEqual++;
        }
    else
    {
        below++;
    }
    }
    System.out.println("Average of score is" + average);
    System.out.println("Number of scores above or equal to average is" + aboveOrEqual);
    System.out.println("Number of scores below average" + below);
     }
    

}


6.


import java.util.Scanner;
public class karyeeTest6{

     public static void main(String []args){
    int num=0;
    double[] values=new double[10];
    Scanner input= new Scanner(System.in);
    System.out.println("Enter 10 values");
    for (int i=0;i<values.length;i++)
    {
        values[i]=input.nextDouble();
    }
    System.out.println("Average of integer" + (int)average(values));
    System.out.println("Average of double values" + average(values));
     }
    
    public static int average(int[] array)
    {
        int sum=0;
        for (int i=0;i <array.length;i++)
        {
            sum += array[i];
        }
        int average=sum/array.length;
        return average;
    }
    public static double average(double[] array)
    {
        double sum=0;
        for(int i=0; i<array.length;i++)
        {
            sum+= array[i];
        }
        double average=sum/array.length;
        return average;
    }

}



7.


import java.util.Scanner;
public class karyeeTest7{

     public static void main(String []args){
    int num=0;
    double[] values=new double[10];
    Scanner input= new Scanner(System.in);
    System.out.println("Enter 10 values");
    for (int i=0;i<values.length;i++)
    {
        values[i]=input.nextDouble();
    }
   System.out.println("The maximum value is" + max(values));
   
    }
    public static double max(double[]array)
    {
        double max=0.0;
        for (int i=0;i<array.length;i++)
        {
            if(array[i]>max)
            max=array[1];
        }
        return max;
    }

}



8.
import java.util.Scanner;
public class Test8{
     public static void main(String []args){
    Scanner input= new Scanner(System.in);
    System.out.println("Enter number of student");
    int n=input.nextInt();
    int[] noOfStudents=new int[n];
    String[] name=new String[n];
    int[] score=new int [noOfStudents.length];
    System.out.println("Enter each student's name and score");

    for (int i=0;i<noOfStudents.length;i++)
    {
        System.out.println("Student" + (i+1) + "\nName:" + " ");
        name[i]=input.next();
        System.out.println("Score: ");
        score[i]=input.nextInt();
    }

    sortDecreasing(name,score);
    for (String e:name)
    {
        System.out.println(e);
    }

    }

    public static void sortDecreasing(String[]name, int[] noOfStudents)
    {
        for (int i=0; i<noOfStudents.length;i++)
        {
            int max = noOfStudents[i];
            int maxIndex=i;
            String temp;
            for(int j=i;j<noOfStudents.length;j++)
            {
                if (noOfStudents[j]>max)
                {
                    max = noOfStudents[j];
                    maxIndex=j;
                }
            }
            if(maxIndex !=i)
            {
                temp=name[i];
                name[i]=name[maxIndex];
                name[maxIndex]=temp;
                noOfStudents[maxIndex]=noOfStudents[i];
                noOfStudents[i]=max;
            }
        }
    }

}



Monday, 17 December 2018

Lab 8
Choong Kar Yee
182630

1.


import java.util.Scanner;
public class Test1{
public static void main(String[] args){
Scanner input=new Scanner(System.in);

int i=1;
int noOfStudents=2;

while(i<= noOfStudents){
System.out.println("Enter first test score");
double test1=input.nextDouble();
System.out.println("Enter second test score");
double test2=input.nextDouble();
System.out.println("Enter labwork score");
double labwork=input.nextDouble();
System.out.println("Enter final exam score");
double exam=input.nextDouble();

double mark=test1+test2+labwork+exam;


System.out.println("Enter the mark" + mark);
System.out.println("Your grade is " + grade(mark));
i++;
}}

public static char grade(double mark){

char grade;

if (mark>=80)
{
grade='A';
}
else if (mark>=60)
{
grade='B';
}
else grade='F';

return grade;
}
}


2.

import java.util.Scanner;
public class Test2{
public static void main(String[] args){
Scanner input=new Scanner(System.in);

//System.out.println("Enter a character");
//char a=input.next().CharAt(0);
System.out.println("Enter a String");
String str=input.nextLine();

System.out.println("The number of letters in the string \"" + str + "\": " + countLetters(str));


}

public static int countLetters(String str){


int count =0;
for (int i=0; i<str.length();i++)
{
if (Character.isLetter(str.charAt(i)))

count++;
}
return count;
}
}




import java.util.Scanner;
public class Test2_b {
/** Main Method */
public static void main(String[] args) {
Scanner input = new Scanner(System.in); // Create a Scanner

// Prompt the user to enter a string followed by a character
System.out.print(
"Enter a string followed by a character e.g. Welcome, e : " );
String string = input.nextLine();

// Extract character and substring
int k = string.indexOf(", ");
String str = string.substring(0, k);
char ch = string.charAt(k + 2);

// Display the nubmer of occurrences of the character in the string
System.out.println(
"The number of occurrences of \"" + ch + "\" in \'" + str + "\" is: " +
count(str, ch));

}

/** Method count */
public static int count(String str, char a) {
int count = 0; // Initialize count to 0

// Count the number of occurrences of the character a in the string str
for (int i = 0; i < str.length(); i++) {
if (a == str.charAt(i))
count++;
}
return count;
}
}




https://github.com/jsquared21/Intro-to-Java-Programming/blob/master/Exercise_06/Exercise_06_23/Exercise_06_23.java

Wednesday, 21 November 2018

Lab 7
Choong Kar Yee
182630

1.
public class test1 {
          public static void main (String[] args) {
                  int x = 8000000;
                   while ( x > 0 )
                    x++;
                  System.out.println( “x is “ + x );
}
}
asnwer is -2147483648. A variable being assigned to the largest value, answer will eventually reached the maximum which is  2147483647. &

2.
public class test2 {
public static void main (String[] args) {
int s = 1, n = 0;
boolean b;
while (n < 10)
{
n++;
s += n;
b = (n % 2==0);
System.out.println( " n = " + n + " and b = " + b);
if (s > 5)
{
System.out.println( “s = “ +s);
break;
}
}
}
}




3.
import java.util.Scanner;
public class Test3{
public static void main (String []args){
Scanner input = new Scanner(System.in);

int number;
int sum = 0;
do
{
System.out.println("Enter an integer. The input ends if it is 0. ");
number = input.nextInt();

sum += number;
}
while(number != 0 );
System.out.println("Enter an integer. The input ends if it is 0.");



}

}

4.
public class test4 {
public static void main (String[] args) {
for (int count=1;count<=100;count++)
System.out.println( count );
}
}


5.


while loop:

long sum = 0;
int i = 0;
while (i <= 1000);
int i=input.nextInt();

 sum + = i++;

do-while loop:

long sum=0;
int i=0;
do
{
sum+=i++;
}
while (i<=1000);


6.

i is 0, printIn statement executed.
i is 1, printIn statement executed once.
i is 2, printIn statement executed twice.
...
i is 9, printIn statement executed nine times.

Total : 0+1+2+3+4+5+6+7+8+9=45


7.
import java.util.Scanner;
public  class Test7{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter a String");
String string=input.nextLine();
int vowels=0;
int consonants=0;

for(int i=0; i<string.length();i++){
if(Character.isLetter(string.charAt(i))){
if(Character.toUpperCase(string.charAt(i))=='A'||
Character.toUpperCase(string.charAt(i))=='E'||
Character.toUpperCase(string.charAt(i))=='I'||
Character.toUpperCase(string.charAt(i))=='O'||
Character.toUpperCase(string.charAt(i))=='U')
{
vowels++;
}
else
consonants++;
}
System.out.println("The number of vowels is" + vowels );
System.out.println("the number of consonants is" + consonants);
}
}
}





8.


import java.util.Scanner;
public class Test8{
public static void main(String[] args){
Scanner input=new Scanner(System.in);

int highestScore=0;
String highestScoreName="";

System.out.println("Enter number of students:");
int numberOfStudents=input.nextInt();

System.out.println("Enter student's name and test 1 score");
for(int i=0;i<numberOfStudents;i++){
System.out.print("Student"+(i+1)+"\n   Name:   ");
String name=input.next();
System.out.print("Score is");
int score=input.nextInt();

if(score>highestScore)
{
highestScore=score;
highestScoreName=name;
}
}
System.out.println("Student with highest score is " + highestScoreName);
}
}



9


import java.util.Scanner;
public class Test9{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int computer,player;
int point=1,computerPoint=0,playerPoint=0;

System.out.println(" Rock paper scissor game");
while((playerPoint!=3)&&(computerPoint!=3))
{
System.out.println("Enter 1-Scissor  2-Rock  3-Paper");
player=input.nextInt();
computer=(1+(int)(Math.random()*3));

if((computer==1)&&(player==3))
{
System.out.println("Scissor vs Paper. You lose");
computerPoint+=point;
}
else if((computer==2)&&(player==1))
{
System.out.println("Rock vs Scissor.You lose");
computerPoint+=point;
}
else if((computer==3)&&(player==2))
{
System.out.println("Paper vs Rock.You lose");
computerPoint+=point;
}
else if((computer==1)&&(player==2))
{
System.out.println("Scissor vs Rock.You win");
playerPoint+=point;
}
else if((computer==2)&&(player==3))
{
System.out.println("Rock vs paper.You win");
playerPoint+=point;
}
else if((computer==3)&&(player==1))
{
System.out.println("Paper Scissor.You win");
playerPoint+=point;
}
else if((computer==1)&&(player==1))
{
System.out.println("Scissor vs Scissor.Draw");
}
else if((computer==2)&&(player==2))
{
System.out.println("Rock vs Rock.Draw");
}
else if((computer==3)&&(player==3))
{
System.out.println("Paper vs Paper.Draw");
}
else
System.out.println(" Please choose between 1,2,3");
}
if(computerPoint>=3)
System.out.println("You lose");
else if(playerPoint>=3)
System.out.println("You Win");
}
}





10





Phewwwww..... That is all for today lab!





Wednesday, 24 October 2018

LAB 6
Choong Kar Yee
182630
1. 
public class Q1 {
public static void main(String[] args) {

System.out.printf( "%6b", ( 1 > 2 ) );
System.out.printf( "%6s\n", "Java");
System.out.printf("Amount is %f %e", 32.32, 32.32);
System.out.printf("%8d%8.1f", 1234, 5.6321);
System.out.printf("%-8d%-8.1f", 1234, 5.6321);

}
}



2.

public class Q2 {
public static void main(String[] args) {

String s1 = "Welcome to Java";
String s2 = "Welcome to Java";
String s3 = new String("Welcome to Java");
System.out.println( s1 == s2);
System.out.println( s1 == s3);

}
}



3.

import java.util.Scanner;
public class Q3 {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.print("Enter 2 name,sister1:");
String sister1= input.nextLine();
System.out.print("sister2:");
String sister2= input.nextLine();

if (sister1.compareTo(sister2)<0)
{
System.out.println("sister1 is smaller than sister2");
}
else if (sister1.compareTo(sister2)>0)
{
System.out.println("sister1 is greater than sister2");
}
else
{
System.out.println("They are same age!");
}
}
}


4.

public class Q4 {
public static void main(String[] args) {
int number=(int)(Math.random()* 10 +'a');
System.out.println((char)(number));

}
}



5.
import java.util.Scanner;
public class Q5 {
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.print("Enter a character:");
char E =input.next().charAt(0);
int ASCII =(int)E;

System.out.println("The ASCII code for character" + E + "is" + ASCII);

}
}


6.

import java.util.Scanner;
public class Q61 {
public static final int PASSWORD_LENGTH = 8;
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.print("A password must have at least eight characters.\n" +
"A password consists of only letters and digits.\n" +
"A password must contain at least two digits.");
System.out.print("Enterpassword");
String password= input.nextLine();

        if (isValid(password)) {
            System.out.println("Valid Password");
        } else {
            System.out.println("Invalid Password");
        }
    }
    public static boolean isValid(String password) {
        if (password.length() < 8) { 
            return false;
        } else {    
            char c;
            int count = 1; 
            for (int i = 0; i < password.length() - 1; i++) {
                c = password.charAt(i);
                if (!Character.isLetterOrDigit(c)) {        
                    return false;
                } else if (Character.isDigit(c)) {
                    count++;
                    if (count < 2)   {   
                        return false;
                    }   
                }
            }
        }
        return true;
    }
}
LAB 5
Choong Kar Yee
182630

SWITCH STATEMENT
Tell you secretly
This is my favourite topic among others! 😌


Let's begin!

1.
a. ( true ) && ( 3 > 4 ) – FALSE
b. ! ( x > 0 ) && ( x > 0 ) – FALSE
c. ( x > 0 ) || ( x < 0 ) – TRUE 
d. ( x != 0 ) || ( x = = 0 ) – TRUE
e. ( x >= 0 ) || ( x < 0 ) – TRUE
 f. ( x != 1 ) = = !( x = = 1 )- TRUE

2.
public class no2
public static void main(String[] args) {
int x=1, a=3;
switch (a) {
case 1: System.out.println (x+=5);
break;
case 2: System.out.println (x+=10);
break;
case 3: System.out.println (x+=16);
break;
case 4: System.out.println (x+=34);
}



3.
y =2
x=3;
y=3;
if (x+3==6)
{
y=1;
y+=1

4.
public class Day 
public static void main(String[] args) {
swtich (day){
case 0:System.out.println("Sunday");
break;
case 1:System.out.println("Monday");
break;
case 2:System.out.println("Tueday");
break;
case 3:System.out.println("Wednesday");
break;
case 4:System.out.println("Thursday");
break;
case 5:System.out.println("Friday");
break;
case 6:System.out.println("Saturday");
}
}

5.
public class Day 
public static void main(String[] args) {
swtich (month){
case 1:System.out.println("January");
break;
case 2:System.out.println("February");
break;
case 3:System.out.println("March");
break;
case 4:System.out.println("April");
break;
case 5:System.out.println("May");
break;
case 6:System.out.println("June");
break;
case 7:System.out.println("July");
break;
case 8:System.out.println("August");
break;
case 9:System.out.println("September");
break;
case 10:System.out.println("October");
break;
case 11:System.out.println("November");
break;
case 12:System.out.println("December");

}
}

6.
((age>=6)?"ticketPrice=20":"ticketPrice=10");


7.
a. 
score = ( x > 10 ) ? 3 * scale : 4 * scale;

if (x>10)
score= 3*scale;
else
score=4*scale;

b.
tax = ( income > 10000 ) ? income * 0.2 : income * 0.17 + 1000;


if(income>10000)
tax=income* 0.2;
else
tax=income*0.17+1000;


c.
System.out.println( ( number % 3 == 0 ) ? i : j );

if ( number % 3 == 0 )
System.out.printIn(i);
else
System.out.printIn(j);


8.
import java.util.Scanner;
public class SortNumber {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter three numbers:");
int w = input.nextInt();
int x = input.nextInt();
int y = input.nextInt();

if (w<x)
{
if (x<y)
{
System.out.println("The numbers are sorted.");
}
else
{
System.out.println("The number are not sorted");
}
}
else
{
System.out.println("The numbers are not sorted.");
}
}
}



b.
import java.util.Scanner;
public class SortNumber1 {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter three numbers:");
int w = input.nextInt();
int x = input.nextInt();
int y = input.nextInt();

if ((w<x)&&(x<y))
{
System.out.println("The numbers are sorted.");
}
else
{
System.out.println("The numbers are not sorted.");
}
}
}


9.
import java.util.Scanner;
public class Tax {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter filling status:0 for single filers, 1 for married filling jointly or qualified widow(er), 2 for married filing separately, 3 for head of household.");
int filingStatus=input.nextInt();
System.out.print("Enter taxableIncome");
int taxableIncome=input.nextInt();


double tax=0.0;
switch (filingStatus){
case 0:
if (taxableIncome>82250)
System.out.println(tax=(0.10*8350)+0.30*(taxableIncome-82250));
if (taxableIncome>33950)
System.out.println(tax=(0.10*8350)+0.25*(taxableIncome-33950));
if (taxableIncome>8350)
System.out.println(tax=(0.10*8350)+0.15*(taxableIncome-8350));
else
System.out.println(tax=0.10*taxableIncome);
break;

case 1:
if (taxableIncome>137050)
System.out.println(tax=(0.10*16700)+0.30*(taxableIncome-137050));
if (taxableIncome>67900)
System.out.println(tax=(0.10*16700)+0.25*(taxableIncome-67900));
if (taxableIncome>16700)
System.out.println(tax=(0.10*16700)+0.15*(taxableIncome-16700));
else
System.out.println(tax=0.10*taxableIncome);
break;

case 2:
if (taxableIncome>68525)
System.out.println(tax=(0.10*68525)+0.30*(taxableIncome-68525));
if (taxableIncome>67900)
System.out.println(tax=(0.10*33950)+0.25*(taxableIncome-33950));
if (taxableIncome>16700)
System.out.println(tax=(0.10*8350)+0.15*(taxableIncome-8350));
else
System.out.println(tax=0.10*taxableIncome);
break;

case 3:
if (taxableIncome>117450)
System.out.println(tax=(taxableIncome-117450)*0.30);
if (taxableIncome>45500)
System.out.println(tax=(taxableIncome-45500)*0.25);
if (taxableIncome>11950)
System.out.println(tax=(taxableIncome-11950)*0.15);
else
System.out.println(tax=taxableIncome*0.10);
break;
default: System.out.println("Error: Invalid status");
}
System.out.println("Total tax is " + tax);
}
}


lab 10 1. import java.util.Scanner; public class Test1{      public static void main(String []args){               Scanner input =...