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

Record Program 10th

Uploaded by

mail2mnl01
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)
36 views3 pages

Record Program 10th

Uploaded by

mail2mnl01
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/ 3

1.

Write a program to display the first ten terms of the series:


5, 10, 17, --------------

public class SeriesProgram {


public static void main(String[] args) {
int term = 5;
int constantValue = 5;

System.out.print("First ten terms of the series: ");


for (int i = 0; i < 10; i++) {
System.out.print(term + " ");

// Calculate the next term in the series


term = term + constantValue;

// Increase the constant value by 2 for each iteration


constantValue += 2;
}
}
}

2.Write a program to display the given pattern:


11111
3333
555
77
9

public class LeftSidePattern {


public static void main(String[] args) {
int rows = 5;

for (int i = 1; i <= rows; i++) {


// Print numbers
for (int k = 1; k <= i; k++) {
System.out.print((2 * i - 1) + " ");
}

System.out.println();
}
}
}
3.Write a program to input a number. Find the sum of digits and the number of digits. Display
the output.
Sample Input: 4539
Sum of digits = 21
Number of digits = 4

ans)import java.util.Scanner;

public class SumAndDigits {


public static void main(String[] args) {
// Create a Scanner object to read input from the user
Scanner scanner = new Scanner(System.in);

// Input a number from the user


System.out.print("Enter a number: ");
int number = scanner.nextInt();

// Close the Scanner since we have collected the input


scanner.close();

int sum = 0;
int numberOfDigits = 0;
int tempNumber = number;

// Calculate the sum of digits and count the number of digits


while (tempNumber != 0) {
int digit = tempNumber % 10;
sum += digit;
numberOfDigits++;
tempNumber /= 10;
}

// Display the results


System.out.println("Sum of digits = " + sum);
System.out.println("Number of digits = " + numberOfDigits);
}
}

4.Write a java program for the given type of number.A number is said to be Duck
if the digit zero is (0) present in it.
Sample Input: 5063
Sample Output: It is a Duck number.
Sample Input: 7453
Sample Output: It i
s not a Duck number.
—------------------------------------------------------------
5.Write a menu driven class to accept a number from the user and check whether it
is a Palindrome or a Perfect number.
(a) Palindrome number: (A number is a Palindrome which when read in reverse
order is same as in the right order)
Example: 11, 101, 151 etc.
(b) Perfect number: (A number is called Perfect if it is equal to the sum of its
factors other than the number itself.)
Example: 6 = 1 + 2 + 3
—------------------------------------------------------------------
6.Write a program to display all the 'Buzz Numbers' between p and q (where p<q).
A 'Buzz Number' is the number which ends with 7 or is divisible by 7.

You might also like