package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { // write your code here int table; Scanner table1 = new Scanner(System.in); System.out.print("Enter Table number : "); table= table1.nextInt(); for(int i=1 ;i<=10;i++) { System.out.println(table +" x " +i +" = " +table*i); } } }
Enter Table number : 12
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120
Process finished with exit code 0
11 . The distance between two cities (in km is input through the keyboard. write a program to convert and print this distance in meter ,feet inches and centimeter. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here System . out . print ( "Enter distance between two cities : " ); Scanner sc = new Scanner ( System . in ); //sc is scanner name double distance , meter , feet , inches , centimetres ; //variable is declared distance = sc . nextDouble (); //taking input from user (in km) meter = distance * 1000 ; //1km = 1000m feet = distance * 3280.8399 ; //1km = 3280.8399; inches = distance * 39370.0787 ; //1km = 39370.0787; centimetres = distance * 100000 ; //1km = 100000; System . out . println ( distance + " kilometer = " + meter + " meter" ); System . out . println ( distance + " k...
BITWISE OPERATOR package com.company ; public class Main { public static void main ( String [] args ) { //AND operator int x = 10 , y = 6 , z ; z = x & y ; //both bits should be 1 /* x y x&y 0 0 0 0 1 0 1 0 0 1 1 1 */ System . out . println ( "z=x&y : " + z ); //OR bitwise operator z = x | y ; //one of bits should be 1 /* x y x|y 0 0 0 0 1 1 1 0 1 1 1 1 */ System . out . println ( "z=x|y : " + z ); //XOR bitwise operator z = x ^ y ; //only one bits should be 1 /* x y x^y 0 0 0 0 1 0 1 0 0 1 1 0 */ System . out . println ( "z=x^y : " + z ); /*LEFT SHIFT operator * It will double the number by moving 1 place * Automati...
Comments
Post a Comment