- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
Conditional Constructs in Java
Chapter 8
Conditional Constructs in Java
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
![]() Share with a Friend |
Assignment Questions and Programs
- 1. Assignment Questions and Answers (1 to 16)
- 17. Write a program to find the number of and sum of all integers greater than 500 and less than 1000 that are divisible by 17.
- 18. Create a program to find out if the number entered by the user is a two, three or four digits number.
Sample input: 1023
Sample output: 1023 is a 4 digit number. - 19. Write a program in Java that reads a word and checks whether it begins with a vowel or not.
20. Write a program in Java to read three integers and display them in descending order.
21. Using the ternary operator, create a program to find the largest of three numbers.
22. Write a program that reads a month number and displays it in words.
23. Admission in a professional course is subject to the following criteria:
- Marks in Physics >= 70
- Marks in Chemistry >= 60
- Marks in Mathematics >= 70
- Total marks in all subjects >= 225
Or
Total marks in Physics and Mathematics >= 150
Write a program in Java to accept marks in these 3 subjects (Physics, Chemistry, and Mathematics) and display if a candidate is eligible.
24. Using the switch statement in Java, write a program to display the name of the city according to the user's choice.
D — Delhi, M — Mumbai, K — Kolkata, C — Chennai25. Write a program that will read the value of x and compute the following function:
26. Employees at Arkenstone Consulting earn the basic hourly wage of Rs.500. In addition to this, they also receive a commission on the sales they generate while tending the counter. The commission given to them is calculated according to the following table:
Total Sales
Commmision Rate
Rs. 100 to less than Rs. 1000
1%
Rs. 1000 to less than Rs. 10000
2%
Rs. 10000 to less than Rs. 25000
3%
Rs. 25000 and above
3.5%
Write a program in Java that inputs the number of hours worked and the total sales. Compute the wages of the employees.
27. Write a program in Java to compute the perimeter and area of a triangle, with its three sides given as a, b, and c using the following formulas:
28. Mayur Transport Company charges for parcels as per the following tariff:
Weight
Charges
Upto 10 Kg.
Rs. 30 per Kg.
For the next 20 Kg.
Rs. 20 per Kg.
Above 30 Kg.
Rs. 15 per Kg.
Write a program in Java to calculate the charge for a parcel, taking the weight of the parcel as an input.
29. Create a program in Java to find out if a number entered by the user is a Duck Number.
A Duck Number is a number which has zeroes present in it, but there should be no zero present in the beginning of the number. For example, 6710, 8066, 5660303 are all duck numbers whereas 05257, 080009 are not.
30. The electricity board charges the bill according to the number of units consumed and the rate as given below:
Units Consumed
Rate Per Unit
First 100 units
80 Paisa per unit
Next 200 units
Rs. 1 per unit
Above 300 units
Rs. 2.50 per unit
Write a program in Java to accept the total units consumed by a customer and calculate the bill. Assume that a meter rent of Rs. 500 is charged from the customer.
31. Write a menu driven program to accept a number from the user and check whether it is a Buzz number or an Automorphic number.
i. Automorphic number is a number, whose square's last digit(s) are equal to that number. For example, 25 is an automorphic number, as its square is 625 and 25 is present as the last two digits.
ii. Buzz number is a number, that ends with 7 or is divisible by 7.32. Write a Java program in which you input students name, class, roll number, and marks in 5 subjects. Find out the total marks, percentage, and grade according to the following table.
Percentage
Grade
>=90
A+
>=80 and <90
A
>=70 and <80
B+
> =60 and <70
B
>=50 and <60
C
>=40 and <50
D
<40
E
33. Write a program in Java to accept three numbers and check whether they are Pythagorean Triplet or not. The program must display the message accordingly. [Hint: h2=p2+b2]
34. Using switch case, write a program to convert temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.
Fahrenheit to Celsius formula: (32°F - 32) x 5/9
Celsius to Fahrenheit formula: (0°C x 9/5) + 3235. Star mall is offering discount on various types of products purchased by its customers. Following table shows different type of products and their respective code along with the discount offered. Based on the code entered, the mall is calculating the total amount after deducting the availed discount. Create a program to calculate total amount to be paid by the customer.
Item
Item Code
Discount
Laptop
L
5%
LCD
D
7%
XBox
X
10%
Printer
P
11%
36. A cloth showroom has announced the following festival discounts on the purchase of items based on the total cost of the items purchased:
Total Cost
Discount Rate
Less than Rs. 2000
5%
Rs. 2000 to less than Rs. 5000
25%
Rs. 5000 to less than Rs. 10,000
35%
Rs. 10,000 and above
50%
Write a program to input the total cost and to compute and display the amount to be paid by the customer availing the discount.
37. A cloth manufacturing company offers discounts to the dealers and retailers. The discount is computed using the length of the cloth as per the following table:
Length of cloth
Dealer's Discount
Retailer's Discount
Up to 1000 meters
20%
15%
Above 1000 meters but less than 2000 meters
25%
20%
More than 2000 meters
35%
25%
Write a program in Java to input the length of the cloth and the total amount of purchase. The program should display a menu to accept type of customer — Dealer (D) or Retailer (R) and print the amount to be paid. Display a suitable error message for a wrong choice.
38. Using switch case statement in Java, create a program to convert rupee into dollar and dollar into rupee according to the user's choice. Assume conversion price: 1 Dollar = Rs.77.
39. A box of cookies can hold 24 cookies, and a container can hold 75 boxes of cookies. Write a program that prompts the user to enter the total number of cookies, the number of cookies in each box, and the number of cookies boxes in a container. The program then outputs the number of boxes and the number of containers required to ship the cookies.
40. Write a menu driven program to display the following menu:
Conversion Table
============- Milliseconds to Seconds
- Milliseconds to Minutes
- Seconds to Milliseconds
- Seconds to Minutes
- Minutes to Milliseconds
- Minutes to Seconds
For an incorrect choice, display an appropriate error message.
Hint: 1 second = 1000 milliseconds
41. Using the switch statement, write a menu driven program:
- To check and display whether a number input by the user is a composite number or not.
A number is said to be composite, if it has one or more than one factors excluding 1 and the number itself.
Example: 4, 6, 8, 9... - To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2
For an incorrect choice, an appropriate error message should be displayed.
- To check and display whether a number input by the user is a composite number or not.
42. A new taxi service based on electric vehicles is offering services within a metro city. Following is the fare chart including the type of taxi used to commute and price per kilometer. Create a program to calculate total fare depending on the distance travelled in kilometers.
Type
Fare
Micro
10.05/Km
Macro
15.05/Km
Shared
7.05/Km
43. The City Library charges late fine from members if the books were not returned on time as per the following table:
Number of days late
Magazines fine per day
Text books fine per day
Up to 5 days
Rs. 1
Rs. 2
6 to 10 days
Rs. 2
Rs. 3
11 to 15 days
Rs. 3
Rs. 4
16 to 20 days
Rs. 5
Rs. 6
More than 20 days
Rs. 6
Rs. 7
Using the switch statement, write a program in Java to input name of person, number of days late and type of book — 'M' for Magazine and 'T' for Text book. Compute the total fine and display it along with the name of the person.
