Continue Get link Facebook X Pinterest Email Other Apps - September 13, 2020 package loops;public class Break { public static void main(String[] args) { for(int i = 1; i<=100 ; i++) { if(i==35)break; System.out.println(i); } } } Get link Facebook X Pinterest Email Other Apps Comments
Simple Intrest - September 13, 2020 package userInput; import java.util.Scanner; public class ScannerUserInput { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter Principal"); int principal = sc.nextInt(); System.out.println("Enter Rate"); float rate = sc.nextFloat(); System.out.println("Enter Time"); int time = sc.nextInt(); float simpleIntrest= principal * rate * time /100; System.out.println("The Simple Intrest is:" + simpleIntrest); } } Read more
Automatic Type Casting - June 24, 2021 package type_casting; public class Type_Casting_narrowing { public static void main(String[] args) { double my_double = 2.8965; System.out.println(my_double); int my_int = (int)my_double; System.out.println(my_int); } } Read more
Find Palindrome Number - September 18, 2020 package whileLoops; import java.util.Scanner; public class PalindromeNumber { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int temp = n; int reversedNumber = 0; while(temp>0) { int lastDigit = temp % 10; reversedNumber = reversedNumber * 10 + lastDigit; temp /= 10; } if (reversedNumber == n) { System.out.println(n+ " is palindrome"); } else { System.out.println(n + " is not a palindrome"); } } } Read more
Comments
Post a Comment