Sunday, 5 November 2017

java full trikey question



Problem 07:
What is the output of  the following question
  float income=12000,tax=0;
 if (income <= 10000)
tax = income * 0.1f;
else if (income <= 20000)
tax = 1000 +10000;
 System.out.println(tax);

Output:
11000
Problem 08:
What is the output of  the following question
float income=12000,tax=0;
if (income <= 10000)
tax = income * 0.1f;
else if (income > 10000 &&income <= 20000)
tax = 1000 +income*0.15f;
System.out.println(tax);
Output:
2800.0
Problem 09:
What is the output of  the following question you enter 2 3 4
Scanner input= new Scanner(System.in);
     double x = input.nextDouble();
double y = input.nextDouble();
double z = input.nextDouble();
System.out.println("(x < y && y < z) is " + (x < y && y < z));
System.out.println("(x < y || y < z) is " + (x < y || y < z));
System.out.println("!(x < y) is " + !(x < y));
System.out.println("(x + y < z) is " + (x + y < z));
System.out.println("(x + y > z) is " + (x + y > z));
Output:
 2
3
4
(x < y && y < z) is true
(x < y || y < z) is true
!(x < y) is false
(x + y < z) is false
(x + y > z) is true

No comments:

Post a Comment