English

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java [Latest edition]

Advertisements

Chapters

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java - Shaalaa.com
Advertisements

Solutions for Chapter 1.7: Conditional Statements in Java

Below listed, you can find solutions for Chapter 1.7 of CISCE Avichal for Computer Applications [English] Class 10 ICSE.


Review InsightEXERCISES
Review Insight [Page 97]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.7 Conditional Statements in Java Review Insight [Page 97]

Review Insight | Q 1. | Page 97

What is control variable in a switch statement? 

Review Insight | Q 2. | Page 97

In a switch statement, why is it necessary to use break after each case? 

Review Insight | Q 3. | Page 97

Use switch case statement for the given program snippet:

if(a == 100) 
c = a * 2; 
if(a == 200) 
c = a * 4; 
if(a == 600) 
c = a * 10; 
Review Insight | Q 4. | Page 97

Use if else statement for the given snippet:

String st = (a > 0) ? (a % 2 == 0) ? "Positive even" : "Positive odd" : "Negative number"; 
Review Insight | Q 5. (a) | Page 97

Find errors in the following snippet:

int a = 5, b = 3; 
if (a <= b) 
   System.out.println(a); 
else 
   System.out.println(c = a + b); 
Review Insight | Q 5. (b) | Page 97

Find errors in the following snippet:

int p = 10; 
switch (p) 
{
case1: q = p * 2; 
break; 
case2: q = p + 2;
break; 
case3: q = p − 2; 
break; 
}
Review Insight | Q 6. | Page 97

Rewrite the following program segment using if-else statements instead of the ternary operator: 
String grade = (mark >= 90) ? “A” : (mark >= 80) ? “B” : “C”;

EXERCISES [Pages 98 - 102]

Avichal solutions for Computer Applications [English] Class 10 ICSE 1.7 Conditional Statements in Java EXERCISES [Pages 98 - 102]

Multiple Choice Questions:

EXERCISES | Q I. 1. | Page 98

If m, n, p are the three integers, then which of the following holds true, if (m == n) && (n != p)? 

  • 'm' and 'n' are equal

  • 'n' and 'p' are equal

  • 'm' and 'p' are equal

  • None

EXERCISES | Q I. 2. | Page 98

A compound statement can be stated as: 

  • p = in.nextInt();
    q = in.nextInt(); 
  • m = ++a;
    n = --b; 
  • if (a > b) 
    {a++; b--;) 
  • None

EXERCISES | Q I. 3. | Page 98

If ((p > q) && (q > r)) then:

(where p, q and r are three integer numbers) 

  • q is the smallest number

  • q is the greatest number

  • p is the greatest number

  • None

EXERCISES | Q I. 4. | Page 98
if (a < b) 
    c = a;
else
    c = b;

It can be written as:

  • c = (b < a) ? a : b;
  • c = (a != b) ? a : b; 
  • c = (a < b) ? b : a;
  • None

EXERCISES | Q I. 5. | Page 98

If (a < b && a < c)

(where a, b and c are three integer numbers)

  • a is the greatest number

  • a is the smallest number

  • b is the greatest number

  • None

State whether the following statements are 'True' or 'False':

EXERCISES | Q II. 1. | Page 99

if statement is also called as a conditional statement. 

  • True

  • False

EXERCISES | Q II. 2. | Page 99

A conditional statement is essentially formed by using relational operators. 

  • True

  • False

EXERCISES | Q II. 3. | Page 99

An if-else construct accomplishes 'fall through'. 

  • True

  • False

EXERCISES | Q II. 4. | Page 99

In a switch case, when the switch value does not match with any case then the execution transfers to the default case. 

  • True

  • False

EXERCISES | Q II. 5. | Page 99

The break statement may not be used in a switch statement.

  • True

  • False

EXERCISES | Q III. 1. | Page 99

Predict the output:

int m = 3, n = 5, p = 4; 
if (m == n) && (n != p)
   {
   System.out.println(m * n); 
   System.out.println(n % p); 
   }
if ((m != n) || (n == p)) 
   {
   System.out.printIn(m + n); 
   System.out.println(m − n); 
EXERCISES | Q III. 2. (a) | Page 99

Predict the output:

p = 1

int a = 1, b = 2, c = 3; 
switch(p)
   {
   case 1: a++; 
   case 2: ++b;
      break; 
   case 3: c--; 
   }
System.out.println(a + "," + b + "," + c);
EXERCISES | Q III. 2. (b) | Page 99

Predict the output:

p = 3

int a = 1, b = 2, c = 3; 
switch(p) 
   {
   case 1: a++;
   case 2: ++b; 
       break;
   case 3: c--; 
   }
System.out.println(a + "," + b + "," + c);
EXERCISES | Q IV. 1. | Page 99

Convert the following construct as directed:

switch case construct into if-else-if:

switch(n)
{
case 1:
    s = a + b; 
    System.out.println("Sum = " + s);
    break;
case 2:
    d = a − b;
    System.out. println("Difference = " + d); 
    break;
case 3:
    p = a * b;
    System.out.println("Product = " + p); 
    break; 
default:
    System.out.println("Wrong Choice!"); 
}
EXERCISES | Q IV. 2. | Page 99

Convert the following construct as directed:

if-else-if construct into switch case:

if (var == 1) 
    System.out.println("Distinction"); 
else if (var == 2) 
    System.out.println("First Division"); 
else if (var == 3) 
    System.out.println("Second Division"); 
else 
    System.out.println("invalid");

Answer the following questions:

EXERCISES | Q V. 1. | Page 100

What is meant by conditional statements in JavaScript?

EXERCISES | Q V. 2. | Page 100

What is the significance of System.exit(0)?

EXERCISES | Q V. 3. | Page 100

Is it necessary to include default case in a switch statement? Justify. 

EXERCISES | Q V. 4. | Page 100

What will happen if break statement is not used in a switch case? Explain. 

EXERCISES | Q V. 5. | Page 100

When does Fall through occur in a switch statement? Explain. 

EXERCISES | Q V. 6. (i) | Page 100

What is a compound statement? 

EXERCISES | Q V. 6. (ii) | Page 100

Give an example of a compound statement.

EXERCISES | Q V. 7. | Page 100

Explain if-else-if construct with an example.

EXERCISES | Q V. 8. | Page 100

Give two differences between the switch statement and the If-else statement.

Unsolved Programs:

EXERCISES | Q VI. 1. | Page 100

Write a program to input three numbers (positive or negative). If they are unequal then display the greatest number otherwise, display they are equal. The program also displays whether the numbers entered by the user are 'All positive', 'All negative' or 'Mixed numbers'.

Sample Input: 56, -15, 12
Sample Output: The greatest number is 56.
                          Entered numbers are mixed numbers.

EXERCISES | Q VI. 2. | Page 100

A triangle is said to be an 'Equable Triangle', if the area of the triangle is equal to its perimeter. Write a program to enter three sides of a triangle. Check and print whether the triangle is equable or not.

For example, a right angled triangle with sides 5, 12 and 13 has its area and perimeter both equal to 30. 

EXERCISES | Q VI. 3. | Page 100

A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number. Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message “Special 2-digit number” otherwise, output the message “Not a special 2-digit number”

EXERCISES | Q VI. 4. | Page 100

The standard form of quadratic equation is given by: 

ax2 + bx + c = 0, where d = b2 − 4ac, is known as discriminant that determines the nature of the roots of the equation as: 

Condition Nature
if d >= 0 Roots are real
if d < 0 Roots are imaginary

Write a program to determine the nature and the roots of a quadratic equation, taking a, b, c as input. If d = b2 − 4ac is greater than or equal to zero, then display 'Roots are real', otherwise display 'Roots are imaginary'. 

The roots are determined by the formula as: 

`"r"1 = (-b + sqrt(b^2 - 4ac))/(2a), "r"2 = (-b - sqrt(b^2 - 4ac))/(2a)`

EXERCISES | Q VI. 5. | Page 101

An air-conditioned bus charges fare from the passengers based on the distance travelled as per the tariff given below:  

Distance Travelled Fare
Up to 10 km Fixed charge ₹ 80
11 km to 20 km ₹ 6/km
21 km to 30 km ₹ 5/km
31 km and above ₹ 4/km

Design a program to input distance travelled by the passenger. Calculate and display the fare to be paid. 

EXERCISES | Q VI. 6. | Page 101

An ICSE school displays a notice on the school notice board regarding admission in Class XI for choosing stream according to marks obtained in English, Maths and Science in Class 10 Council Examination.  

Marks obtained in different subjects Stream
Eng, Maths and Science >= 80% Pure Science
Eng and Science >= 80%, Maths >= 60% Bio. Science
Eng, Maths and Science >= 60% Commerce

Print the appropriate stream allotted to a candidate. Write a program to accept marks in English, Maths and Science from the console.

EXERCISES | Q VI. 7. | Page 101

A bank announces new rates for Term Deposit Schemes f ir their customers and Senior Citizens as given below: 

Term Rate of Interest (General) Rate of Interest (Senior Citizen)
Up to 1 year 7.5% 8.0%
Up to 2 years 8.5% 9.0%
Up to 3 years 9.5% 10.0%
More than 3 years 10.0% 11.0%

The senior citizen rates are applicable to the customers whose age is 60 years or more. Write a program to accept the sum (p) in term deposit scheme, age of the customer and the term. The program displays the information in the following format: 

Amount Deposited Term Age Interest earned Amount Paid
xxx xxx xxx xxx xxx
EXERCISES | Q VI. 8. | Page 101

A courier company charges differently for 'Ordinary' booking and 'Express' booking based on the weight of the parcel as per the tariff given below: 

Weight of parcel Ordinary booking Express booking
Up to 100 gm ₹ 80 ₹ 100
101 to 500 gm ₹ 150 ₹ 200 
501 gm to 1000 gm ₹ 210  ₹ 250
More than 1000 gm ₹ 250 ₹ 300

Write a program to input weight of a parcel and type of booking ('O' for ordinary and 'E' for express). Calculate and print the charges accordingly. 

EXERCISES | Q VI. 9. | Page 102

Write a program to input a number and check whether it is a perfect square or not. If the number is not a perfect square then find the least number to be added to input number, so that the resulting number is a perfect square. 

Example 1:
Sample Input: 2025
`sqrt(2025)` = 45
Sample Output: It is a perfect square.

Example 2:
Sample Input: 1950
`sqrt(1950)` = 44.1588.........
Least number to be added = 452 − 1950 = 2025 − 1950 = 75

EXERCISES | Q VI. 10. | Page 102

Write a program that accepts three numbers from the user and displays them either in "Increasing Order" or in "Decreasing Order" as per the user's choice. 

Choice 1: Ascending order
Choice 2: Descending order
Sample Inputs: 394, 475, 296
Choice: 2 
Sample Output:
First number : 475
Second number : 394
Third number : 296
The numbers are in decreasing order. 

Menu Driven/Switch Case programs

EXERCISES | Q VI. 11. | Page 102

Write a menu driven program to calculate:

  1. Area of a circle = p*r*r, where p = `22/7`
  2. Area of a square = side*side
  3. Area of a rectangle = length*breadth

Enter 'c' to calculate area of circle, 's' to calculate area of square and 'r' to calculate area of rectangle. 

EXERCISES | Q VI. 12 | Page 102

Write a program using switch case to find the volume of a cube, a sphere and a cuboid. For an incorrect choice, an appropriate error message should be displayed. 

  1. Volume of a cube = s * s * s
  2. Volume of a sphere = `4/3` π*r*r*r (π = `22/7`)
  3. Volume of a cuboid = l*b*h 
EXERCISES | Q VI. 13. | Page 102

The relative velocity of two trains travelling in opposite directions is calculated by adding their velocities. In case, the trains are travelling in the same direction, the relative velocity is the difference between their velocities. Write a program to input the velocities and length of the trains. Write a menu driven program to calculate the relative velocities and the time taken to cross each other.

EXERCISES | Q VI. 14. | Page 102

In order to purchase an old car, the depreciated value can be calculated as per the tariff given below:

No. of years used Rate of depreciation
1 10%
2 20%
3 30%
4 40%
Above 4 years 50%

Write a menu driven program to input showroom price and the number of years the car is used ('1' for one year old, '2' for two years old and so on). Calculate the depreciated value. Display the original price of the car, depreciated value and the amount to be paid. 

EXERCISES | Q VI. 15. | Page 102

You have a saving account in a bank with some balance amount in your account. Now, you want to perform the following tasks, as per your choice. The tasks are as under: 

1. Money Deposited
2. Money Withdrawn
3. Check balance
0. To quit

Write a menu driven program to take input from the user and perform the above tasks. The program checks the balance before withdrawal and finally displays the current balance after transaction. For an incorrect choice, an appropriate message should be displayed.

Solutions for 1.7: Conditional Statements in Java

Review InsightEXERCISES
Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java - Shaalaa.com

Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java

Shaalaa.com has the CISCE Mathematics Computer Applications [English] Class 10 ICSE CISCE solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. Avichal solutions for Mathematics Computer Applications [English] Class 10 ICSE CISCE 1.7 (Conditional Statements in Java) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.

Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. Avichal textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.

Concepts covered in Computer Applications [English] Class 10 ICSE chapter 1.7 Conditional Statements in Java are Introduction of Conditional Statements in Java, Flow of Control, Normal Flow of Control, Conditional Flow of Control.

Using Avichal Computer Applications [English] Class 10 ICSE solutions Conditional Statements in Java exercise by students is an easy way to prepare for the exams, as they involve solutions arranged chapter-wise and also page-wise. The questions involved in Avichal Solutions are essential questions that can be asked in the final exam. Maximum CISCE Computer Applications [English] Class 10 ICSE students prefer Avichal Textbook Solutions to score more in exams.

Get the free view of Chapter 1.7, Conditional Statements in Java Computer Applications [English] Class 10 ICSE additional questions for Mathematics Computer Applications [English] Class 10 ICSE CISCE, and you can use Shaalaa.com to keep it handy for your exam preparation.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×