Advertisements
Chapters
1.2: Elementary Concept of Objects and Classes
1.3: Values and Data Types
1.4: Operators in Java
1.5: Introduction to Java
1.5: Input in Java
1.6: Mathematical Library Methods
▶ 1.7: Conditional Statements in Java
1.8: Iterative Constructs in Java
1.9: Nested Loop
2: Library Classes
3: Arrays (Single Dimensional and Double Dimensional)
4: String Handling
5: User - Defined Methods
6: Class as the Basis of all Computation (Objects and Classes)
7: Constructors
8: Encapsulation and Inheritance
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
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.
Avichal solutions for Computer Applications [English] Class 10 ICSE 1.7 Conditional Statements in Java Review Insight [Page 97]
What is control variable in a switch statement?
In a switch statement, why is it necessary to use break after each case?
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;
Use if else statement for the given snippet:
String st = (a > 0) ? (a % 2 == 0) ? "Positive even" : "Positive odd" : "Negative number";
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);
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;
}
Rewrite the following program segment using if-else statements instead of the ternary operator:
String grade = (mark >= 90) ? “A” : (mark >= 80) ? “B” : “C”;
Avichal solutions for Computer Applications [English] Class 10 ICSE 1.7 Conditional Statements in Java EXERCISES [Pages 98 - 102]
Multiple Choice Questions:
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
A compound statement can be stated as:
p = in.nextInt(); q = in.nextInt();
m = ++a; n = --b;
if (a > b) {a++; b--;)
None
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
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
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':
if statement is also called as a conditional statement.
True
False
A conditional statement is essentially formed by using relational operators.
True
False
An if-else construct accomplishes 'fall through'.
True
False
In a switch case, when the switch value does not match with any case then the execution transfers to the default case.
True
False
The break statement may not be used in a switch statement.
True
False
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);
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);
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);
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!");
}
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:
What is meant by conditional statements in JavaScript?
What is the significance of System.exit(0)?
Is it necessary to include default case in a switch statement? Justify.
What will happen if break statement is not used in a switch case? Explain.
When does Fall through occur in a switch statement? Explain.
What is a compound statement?
Give an example of a compound statement.
Explain if-else-if construct with an example.
Give two differences between the switch statement and the If-else statement.
Unsolved Programs:
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.
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.
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”
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)`
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.
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.
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 |
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.
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
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
Write a menu driven program to calculate:
- Area of a circle = p*r*r, where p = `22/7`
- Area of a square = side*side
- 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.
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.
- Volume of a cube = s * s * s
- Volume of a sphere = `4/3` π*r*r*r (π = `22/7`)
- Volume of a cuboid = l*b*h
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.
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.
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
![Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java Avichal solutions for Computer Applications [English] Class 10 ICSE chapter 1.7 - Conditional Statements in Java - Shaalaa.com](/images/computer-applications-english-class-10-icse_6:1e1eb1b47d2b4696b609e5cd9260118f.jpg)
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.