Array Programs Class 10TH
Array Programs Class 10TH
int acc_num;
String title;
String author;
Program 2- Given below is a hypothetical table showing rates of Income Tax for male
citizens below the age of 65 years:
Is greater than 1,60,000 and less than or equal to 5,00,000 ( TI – 1,60,000 ) * 10%
Is greater than 5,00,000 and less than or equal to 8,00,000 [ (TI - 5,00,000 ) *20% ] + 34,000
Write a program to input the age, gender (male or female) and Taxable Income of a
person.If the age is more than 65 years or the gender is female, display “wrong
category*.
If the age is less than or equal to 65 years and the gender is male, compute and display
the Income Tax payable as per the table given above.
Solution.
import java.util.Scanner;
Program 3- Write a program to accept a string. Convert the string to uppercase. Count
and output the number of double letter sequences that exist in the string.
Sample Input: “SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE
Sample Output: 4
Solution.
import java.util.Scanner;
Example:
(i) Input value of n=2, ch=’O’
Output:
OO
OO
(ii) Input value of x=2, y=5
Output:
@@@@@
@@@@@
(iii) Output:
*
**
***
Solution.
System.out.print(ch);
System.out.println();
System.out.print("@");
System.out.println();
System.out.println();
Program 5- Using the switch statement, writw a menu driven program to:
(i) Generate and display the first 10 terms of the Fibonacci
series 0,1,1,2,3,5….The first two Fibonacci numbers are 0 and 1, and each
subsequent number is the sum of the previous two.
(ii)Find the sum of the digits of an integer that is input.
Sample Input: 15390
Sample Output: Sum of the digits=18
For an incorrect choice, an appropriate error message should be displayed
Solution.
import java.util.Scanner;
switch (choice) {
case 1:
int a = 0;
int b = 1;
System.out.print("0 1 ");
default:
System.out.println("Invalid Choice");
Solution.
import java.util.Scanner;
import java.util.Scanner;
cities[i] = scanner.next();
std[i] = scanner.nextInt();
if (cities[i].equals(target)) {
System.out.println("Search successful");
searchSuccessful = true;
break;
}
if (!searchSuccessful) {