import java.util.
*;
public class LPGbillcalc{// declaring class
public static void main (String[]args){// declaring main method
double fc,ba,r=0;
Scanner sc= new Scanner (System.in);// creating scanner class
System.out.println("Enter the quantity of fuel consumed in the month (in litres): ");
fc= sc.nextDouble();// storing fuel consumed
if (fc<=30 && fc>0)
r=110.0;
else if (fc<=70 && fc>30)
r=120.0;
else if (fc<=130 && fc>70)
r=115.0;
else if (fc>130)
r=140.0;
else{
System.out.println("Monthly bill amount: Rs. 0");
System.exit(0);
ba= fc* r;// calculating bill amount
System.out.println("Monthly bill amount: Rs. "+ba);// printing bill amount
}// end of main method
}// end of class
import java.util.*;
public class GeoCalc{// declaring class
public static void main (String[]args){// declaring main method
int choice;
double s,s1,s2,b,h,r;
Scanner sc = new Scanner (System.in);// creating scanner class
System.out.println("Menu Options:\n\n1. Square\n2. Rectangle\n3. Triangle\n4. Circle\n5. Exit\n\
nEnter your choice");
choice=sc.nextInt();// storing choice;
switch(choice){// printing desired output
case 1:
System.out.println("Enter the length of the side: ");
s= sc.nextDouble();
System.out.println ("The area of the square is "+(s*s)+" sq. units.");
break;
case 2:
System.out.println("Enter the length and breadth: ");
s1= sc.nextDouble();
s2= sc.nextDouble();
System.out.println ("The area of the rectangle is "+(s1*s2)+" sq. units.");
break;
case 3:
System.out.println("Enter the base and height: ");
b= sc.nextDouble();
h= sc.nextDouble();
System.out.println ("The area of the triangle is "+(0.5*b*h)+" sq. units.");
break;
case 4:
System.out.println("Enter the radius of the circle: ");
r=sc.nextDouble();
System.out.println("The area of the circle is "+(Math.PI*r*r)+" sq. units.");
case 5:
System.out.println("Exiting the program. Goodbye!");
System.exit(0);
break;
default:
System.out.println("Invalid choice!");
}// end of main method
}// end of class
import java.util.*;
public class palinorperfect{//declaring class
public static void main (String[]args){//declaring main method
int choice, num, num2,r, rnum=0, s=0, n;
Scanner sc = new Scanner (System.in);// creating scanner class
System.out.println("Menu Options:\n\n1. Palindrome number\n2. Perfect number\n\nEnter your
choice");
choice=sc.nextInt();// storing choice;
switch(choice){// printing desired output
case 1:
System.out.println ("Enter the number");
num=sc.nextInt();
num2=num;
while (num != 0) {
r = num % 10;
rnum = rnum * 10 + r;
num /= 10;
if (num2 == rnum) {
System.out.println(num2 + " is Palindrome.");
}
else {
System.out.println(num2 + " is not Palindrome.");
break;
case 2:
System.out.println ("Enter the number");
n=sc.nextInt();
for (int i = 1; i < n; i++)
if (n % i == 0)
s = s + i;
if (s == n)
System.out.println (n + " Is a perfect number");
else
System.out.println (n + " Is not a perfect number");
break;
default:
System.out.println("Invalid choice!");
}//End of main method
}//End of Class
import java.util.Scanner;
public class DisariumNumbers {//declaring class
public static void main(String[] args) {//declaring main method
Scanner scanner = new Scanner(System.in);//creating scanner class
System.out.print("Enter the first number: ");
int start = scanner.nextInt();
System.out.print("Enter the second number: ");
int end = scanner.nextInt();
System.out.println("Disarium numbers between " + start + " and " + end + ":");
//printing disarium numbers between given range
for (int i = start; i <= end; i++) {
int temp = i;
int sum = 0;
int count = 0;
int numDigits = (int) Math.log10(i) + 1;
while (temp != 0) {
int digit = temp % 10;
sum += Math.pow(digit, numDigits - count);
count++;
temp /= 10;
if (sum == i) {
System.out.println(i);
scanner.close();
}//end of main method
}//end of class
public class NumberPattern {//declaring class
public static void main(String[] args) {//declaring main method
int n = 5; // Number of rows
for (int i = 1; i <= n; i++) {
// Print spaces
for (int j = 1; j <= n - i; j++) {
System.out.print(" "); // Adjust spacing for three-digit numbers
// Print decreasing sequence
for (int j = n; j > n - i; j--) {
System.out.print(j + " "); // Adjust spacing for two-digit numbers
// Print vertical line
for (int j = n - i + 2; j <= n; j++) {
System.out.print(j + " "); // Adjust spacing for two-digit numbers
System.out.println();
}//end of main method
}//end of class