Core Java
Core Java
Java Basics
Estimated Time:7Hrs.
1. Write a program that takes a String through Command Line argument and display
the length of the string. Also display the string into uppercase and check whether
it is a palindrome or not. (Refer Java API Documentation)
2. Write a program that accepts two numbers from the Command Line and prints
them out. Then use a for loop to print the next 13 numbers in the sequence where
each number is the sum of the previous two. For example:
input> java prob2 1 3
output> 1 3 4 7 11 18 29 47 76 123 322 521 843 1364
3. Write a program that accepts two numbers in the range from 1 to 40 from the
Command Line. It then compares these numbers against a single dimension array
of five integer elements ranging in value from 1 to 40. The program displays the
message BINGO if the two inputted values are found in the array element. For
example:
input>java prob3 3 29
output>Your first number was 3
Your second number was 29
Its Bingo! // this message if 3 and 29 is found in the array
Not Found! // this message if 3 and 29 is not found in the
//array
The array was 7 25 5 19 30
4. Write a program that allows you to create an integer array of 18 elements with the
following values: int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0}. The program
computes the sum of element 0 to 14 and stores it at element 15, computes the
average and stores it at element 16 and identifies the smallest value from the array
and stores it at element 17.
conditions:
(i) Hardness must be greater than 50
(ii) Carbon content must be less than 0.7
(iii) Tensile strength must be greater than 5600
The grades are as follows:
Grade is 10 if all three conditions are met
Grade is 9 if conditions (i) and (ii) are met
Grade is 8 if conditions (ii) and (iii) are met
Grade is 7 if conditions (i) and (iii) are met
Grade is 6 if only one condition is met
Grade is 5 if none of the conditions are met
Write a program, which will require the user to give values of
hardness, carbon content and tensile strength of the steel
under consideration and output the grade of the steel.
Dsiplay all values.
14. The policy followed by a company to process customer orders
is given by the following rules:
(a) If a customer order is less than or equal to that in stock
and has credit is OK, supply has requirement.
(b) If has credit is not OK do not supply. Send him
intimation.
(c) If has credit is Ok but the item in stock is less than has
order, supply what is in stock. Intimate to him data the
balance will be shipped.
Write a program to implement the company policy. Display all values.