Write A Program in Java To Make Such A Pattern Like A Pyramid With A Number Which Will Repeat The Numbers in The Same Row
Write A Program in Java To Make Such A Pattern Like A Pyramid With A Number Which Will Repeat The Numbers in The Same Row
Write A Program in Java To Make Such A Pattern Like A Pyramid With A Number Which Will Repeat The Numbers in The Same Row
Write a program in Java to make such a pattern like a pyramid with a number which will
repeat the numbers in the same row.
import java.util.Scanner;
public class PyramidPattern {
int value = 1;
int space = 1;
}
4. Write a Java program that reads a positive integer and count the number of digits the
number (less than ten billion) has.
import java.util.Scanner;
public class IntegerCount {
int count = 0;
System.out.println("Enter the numbers: ");
int number = sc.nextInt();
int numbers = number;
while (number != 0) {
//int digit = number % 10;
number /= 10;
count++;
}
int count = 0;
System.out.println("Enter the number to calculate factorial: ");
int number = sc.nextInt();
int numbers = number;
System.out.println("The factorial of the given number " + numbers + " is: " +
number);
}
}
6. Write a program to check whether a number input by user is prime or not.
import java.util.Scanner;
public class PrimeChecker {
if (!checker) {
System.out.println("The number is prime.");
} else {
System.out.println("The number is not prime.");
}
}
while (number != 0) {
int digit = number % 10;
sum += Math.pow(digit, 3);
number /= 10;
}
number = temp;
if (number == sum) {
System.out.println("The number " + number + " is armstrong.");
} else {
System.out.println("The number " + number + " is not armstrong.");
}
}
8. Write a program to count the number of upper case, lower case, digit and other
character from a string that is taken as input from user.
import java.util.Scanner;
public class Counter {
}
9. Write a program that takes two input from user: a floating-point digit and a precision, a
and round off and display the number to that precision.
import java.text.DecimalFormat;
import java.util.Scanner;
public class RoundOff {
10. Write a program that displays the amount displayed by user in Nepali money format.
11. Write a generalize program for Q20 by asking the format of money from user (e for
English and n for Nepali) and displaying formatted output accordingly.