0% found this document useful (0 votes)
57 views3 pages

Lab Task - 2: Control Statement Related Problems

This document contains problems related to control statements, methods, and arrays in Java. It includes problems such as solving equations based on user input, creating a grading system, determining if an input is alphabetic, numeric or special character, checking for prime numbers, creating a simple calculator with methods for basic math operations, converting between Celsius and Fahrenheit temperatures using methods, finding a factorial using recursion, method overloading to return the maximum of 2 or 3 numbers, performing operations on arrays such as input, output, finding minimum and maximum values, linear search to find an element, and separating positive and negative numbers while calculating the sum.

Uploaded by

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

Lab Task - 2: Control Statement Related Problems

This document contains problems related to control statements, methods, and arrays in Java. It includes problems such as solving equations based on user input, creating a grading system, determining if an input is alphabetic, numeric or special character, checking for prime numbers, creating a simple calculator with methods for basic math operations, converting between Celsius and Fahrenheit temperatures using methods, finding a factorial using recursion, method overloading to return the maximum of 2 or 3 numbers, performing operations on arrays such as input, output, finding minimum and maximum values, linear search to find an element, and separating positive and negative numbers while calculating the sum.

Uploaded by

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

Lab Task – 2

Control Statement related Problems (Any 3)

1. Read four integer values named A, B, C and D. Sole the following equation and print the
result.
a) (A * B - C * D)
b) 2A – B + 3D
c) A 2 + B 2 – C2 + D 2
d) A3 + B –C2
Input
The input file contains 4 integer values.
Output
Print SOLUTION with all the capital letters, according to the following example, with a
blank space before and after the equal signal.
Sample Input Output Sample
5 Solution of Equation - 1 = -26
6 Solution of Equation - 2 = 28
7 Solution of Equation - 3 = 76
8 Solution of Equation - 4 = 67

2. Create a grading system that will display the grade of your obtained mark.
3. Check whether the input is an Alphabet or a digit or a Special Character. If
Alphabet then check whether it is Vowel or Consonant.
Sample Input Output Sample
Test Case = 3 6 is a Digit
6 A is an Alphabet : It is an Vowel
A @ is a special character
@

4. Write a Java Code to check whether an Input is a Prime number or not.


Sample Input Output Sample
Test Case =2 5 is a prime number
5 6 is not a prim number
6

Method related Problems (Any 3)

1. Make a simple calculator using four methods (addition, subtraction,


multiplication and division). Each Method will receive the arguments and will
return the result.

2. Implement the following Temperature conversion function:


i. Function Celsius() returns the Celsius equivalent of a Fahrenheit
temperature, using the calculation:
Celsius = 5.0 / 9.0 * (Fahrenheit - 32)
ii. Function Fahrenheit() returns the Fahrenheit equivalent of a Celsius
temperature, using the calculation:
Fahrenheit = (Celsius * 9.0) / 5.0 + 32
Use the functions from parts (i) and (ii) to write an application that enables
the user to choose either to enter a Fahrenheit temperature and display the
Celsius equivalent or to enter a Celsius temperature and display the
Fahrenheit equivalent.
3. Find out n! using recursion.
4. Write two methods in one class with the same name. One will return the
highest value from two numbers and another will return the highest value
from three numbers. [Method Overloading]

Array related Problems (Any 4)

1. Take input in an array, print the array.


2. Find the smallest and largest value of the array.
3. You have an Array of N numbers. Now write a code to Search an element
from an array input from user. [Linear Search]

Input Samples Output Samples

Total Case = 2 220 is found at Index 1


How many Numbers you want to insert?
5 120 is not found in the Array
Enter 5 array elements
10 220 303 140 50

Case:1
Enter Data You want to search
220
Case:2
Enter Data You want to search
120

4. Take some integer numbers as input in an array. Then display all the
positive and negative numbers separately.
5. Find out the summation of the elements of an array.

You might also like