Java program to find table of any number program: import java.util.*; class table { Scanner sc=new Scanner(System.in); int n; void accept() { System.out.println("enter the number to print its table"); n=sc.nextInt(); } void table() { String s=Integer.toString(n);// covert integer to string for(int i=1;i<=10;i++) { String x=Integer.toString(i);// covert integer to string System.out.println(s+ " x " +x+ " = " +n*i); } } void main() { table ob=new table(); ob.accept(); ob.table(); } } sample output:
Posts
- Get link
- X
- Other Apps
PROGRAM 4: GOLDBACH NUMBER PROGRAM IN JAVA A GoldBach number is a positive even integer that can be expressed as the sum of two odd primes Note: All even integer numbers greater than 4 are GoldBach numbers. Example: 6 = 3 + 3 10 = 3+7 10 = 5+5 Hence 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3 and 7. Write a program to accept an even integer ‘N’ where N>9 and N<50. Find all the odd prime pairs, whose sum is equal to the number ‘N’ Test your program with the following data and some random data. Ex...
- Get link
- X
- Other Apps
JAVA PROGRAM 2 A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12 boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by the user (maximum up to 1000 boxes) and display the break-up of the cartons used in descending order of capacity (i.e. preference should be given to the highest capacity available, and if boxes left are less than 6, an extra carton of capacity 6 should be used.) Test your program with the sample data and some random data: Example 1 INPUT : N = 726 OUTPUT : 48 x 15 = 720 6 x 1 = 6 Remaining boxes = 0 Total number of boxes = 726 Total number of cartons = 16 Example 2 INPUT : N = 140 OUTPUT : 48 X 2 = 96 24 x 1 = 24 12 x 1 = 12 6 x 1 = 6 Remaining boxes 2 x 1 = 2 Total number of boxes = 140 Total number of cartons = 5 Example 3 INPUT : N = 4296 OUTPUT : INVALID LENGTH ALGORITHM...
- Get link
- X
- Other Apps
JAVA PROGRAM FOR DENOMINATIONS A bank intends to design a program to display the denomination of an input amount, up to 5 digits. The available denomination with the bank are of rupees 1000, 500, 100, 50, 20, 10, 5, 2, and 1. Design a program to accept the amount from the user and display the break-up in descending order of denomination. (i.e. preference should be given to the highest denomination available) along with the total number of notes. [Note: Only the denomination used, should be displayed]. Example: INPUT : 14788 OUTPUT : DENOMINATIONS: 1000 x 14 = 14000 500 x 1 = 500 100 x 2 = 200 50 x 1 = 50 20 x 1 = 20 10 x ...