Sunday, 5 November 2017

theory problems in java



Question 07:
Write an if statement that increases pay by 3% if score is greater than 90.
Ans:
int pay=100,g=99;
   if(g>90)
       pay+=pay*0.03;
   System.out.println(pay);
Question 08:
What is if else statement.
Ans:
It has two parts if the condition becomes false it go in its else part.
int pay=100;
   if(pay>90)
   System.out.println(“Your pay  greater then 90”);
   else
       System.out.println(“Your pay less then 90);
Question 09:
What is multi way if else if  and write its syntax.
Ans:
It is applicable on multiple of statements for example to check day of weak etc.
if (score >= 90.0)
System.out.print("A");
else
if (score >= 80.0)
System.out.print("B");
else
if (score >= 70.0)
System.out.print("C");
else
if (score >= 60.0)
System.out.print("D");
else
System.out.print("F");

No comments:

Post a Comment