0% found this document useful (0 votes)
7 views2 pages

Java Exercises 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java Exercises 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

19AIE105 - OBJECT ORIENTED PROGRAMMING

Amrita School of Engineering – Chennai Campus

CSE AI 06-12-2020

JAVA Exercises - 4

1. Write a JAVA program to solve the quadratic equation.


𝑎𝑥 2 + 𝑏𝑥 + 𝑐 = 0

2. JAVA Program to calculate the electricity bill of your home.


For all consumed unit < 100, Rs. 1.20 per unit.
For every consumed unit after 100, till 300, it is Rs.2.00 per Unit.
For all extra units above 300, Rs.3.00 per unit.
Display the total amount of bill to be paid at the end of month.

3. A program to calculate Semester Grade Point Average (SGPA) of your grades.

∑(𝐶𝑜𝑢𝑟𝑠𝑒 𝐺𝑃 ∗ 𝐶𝑜𝑢𝑟𝑠𝑒 𝐶𝑟𝑒𝑑𝑖𝑡𝑠)


𝑆𝐺𝑃𝐴 =
𝐺𝑟𝑎𝑑𝑎𝑙𝑒 𝐶𝑟𝑒𝑑𝑖𝑡𝑠

Grade Course GP
O 10
A+ 9.5
A 9
B+ 8
B 7
C 6
P 5
F 0

4. A Program to calculate Compound interest for N customers.


𝑛𝑡
𝐼𝑛𝑡𝑒𝑟𝑒𝑠𝑡 𝑅𝑎𝑡𝑒
𝐸𝑛𝑑𝑖𝑛𝑔 𝐴𝑚𝑜𝑢𝑛𝑡 = 𝑃𝑟𝑖𝑛𝑐𝑖𝑝𝑎𝑙 (1 + )
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝐶𝑜𝑚𝑝𝑜𝑢𝑛𝑑𝑖𝑛𝑔 𝑎 𝑦𝑒𝑎𝑟

Where ‘n’ is the number of compounding a year and ‘t’ is the total number of
years.

5. A program to find if the given number is Armstrong or not?


Hint: An Armstrong number of three digits is an integer, where the sum of the
cubes of its digits is equal to the number itself.
Eg: 371: 𝑤ℎ𝑒𝑟𝑒 𝑖𝑓 (33 + 73 + 13 == 371)
𝑡ℎ𝑒 𝑔𝑖𝑣𝑒𝑛 𝑛𝑢𝑚𝑏𝑒𝑟 𝑖𝑠 𝑎𝑟𝑚𝑠𝑡𝑟𝑜𝑛𝑔.

1|Page
19AIE105 - OBJECT ORIENTED PROGRAMMING

𝑒𝑙𝑠𝑒 𝑛𝑜𝑡 𝑎𝑟𝑚𝑠𝑡𝑟𝑜𝑛𝑔.

6. Write a program to check if the given character is vowel or consonant. Your


program should be capable of displaying an error message for any other
alphanumeric character being entered.

7. Write a single program capable of doing the following matrix operations. Based
on user input the program has to perform one of these operations.

• Matrix Multiplication
• Sum of Matrices
• Transpose of a matrix
• Display only diagonal elements
• Display only upper triangle elements in matrix.
The program should continue unless user wants to exit.

2|Page

You might also like