Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ASSIGNMENTS FOR PROGRAMMING IN JAVA - I

CONTROL STATEMENTS
1. Fill in the blanks
a. If-else structure helps to make a ____________________________ from the
sequential computation of statements in a program.
b. To select one output of many options in a computation,
___________________ if-else can be used.
c. Switch statement can be used to select one out
________________________ options.
d. The case value in a switch statement must be
_______________________________
e. The ________________________statement tests the condition at the end of
the block.
f. In a for..loop the condition is tested at the ____________________ of the
block.
g. In a for..statement with more than one initializer, there can be more
than one condition.( True / False )
h. The break; statement can be used only in _____________________ and
______________ statements.
2. Write the program for the following:
a. A cloth shop during festival season offers a discount of 10% for the
purchase made up to Rs. 1, 000, 12% for the purchase value between
1,000 and 5,000 and 15% for more than 5,000. Write a program to
implement the above scheme for a given sales and print out the sales
value, discount and net amount payable by a customer.
b. An array of 20 integers is given. Write a Java program to arrange them
in descending order and print them out.
c. Write a program to find the product of two matrices A(3,4) and B(4,2).
d. An electric appliance shop assigns code 1 to motor, 2 to fan, 3 to tube
light and 4 for wires. All other items have a code 5 or more. While
selling the goods, a sales tax of 8% to motor, 12% to fan, 5% to tube
light, 7.5% to wires and 3% for all other items is charged. A list
containing the product code and price is given for making a bill. Write a
Java Program using switch statement to prepare the bill.

Prepared By: Dhiraj Jha (callmedhiraj@gmail.com)

You might also like