JAVA Programming for School

JAVA Programming for School If you have any problems in java programs, just post your question and mention your standard. We wil This page is exclusively made to clear all doubts.

There are certain students who have problems in understanding boolean data types, accepting strings, patterns, Armstrong no, dry run of every program, VDT(Variable Description table), comments, etc. WE WILL TRY OUR BEST!

As a part of a sociology experiment, we are undertaking a survey to determine a correlation between a person's tendency ...
24/09/2018

As a part of a sociology experiment, we are undertaking a survey to determine a correlation between a person's tendency to use public transport with environmental and economic conditions, and distance of travel.

Please fill in the data, and share it for more people to fill in.

This is an anonymous survey that would help us find a more accurate result.

Thanks for participating.

I thank you for participating in this survey. This survey is intended to find out your preferences regarding modes of transportation that you use. This survey is for a college assignment and is not for any commercial use for anyone.

20/08/2017

We are now helping with basic programming in C. Contact us for any basic problem.

17/07/2016

Our dedicated followers,
The admin has noticed misuse of the contents of the page. Somebody is using it directly in their projects and hence we have decided to cease posting any new programs. The page was meant to help you UNDERSTAND the subject better not SHORTEN your homework. We are there to clear your doubts and provide you the algorithm of your program (and in special cases even the program) but only via personal messages.
Yours faithfully,
Admin

25/11/2015

Sorry for this delay.

Write a program in Java to accept a number n (between 1 and 9) and print all possible combinations of '+' and '-' of all natural numbers till n such that their sum is 0.

Eg:
Input: n=7
Output:
-1-2+3-4+5+6-7=0

-1-2+3+4-5-6+7=0

-1+2-3-4+5-6+7=0

-1+2+3+4+5-6-7=0

+1-2-3-4-5+6+7=0

+1-2+3+4-5+6-7=0

+1+2-3-4+5+6-7=0

+1+2-3+4-5-6+7=0

Hint: Logic is to generate a table of (n * 2^n) and fill each row with its binary equivalent of its index. That gives you all the possible combinations of pluses and minuses.
====================================================

Source Code:

class Sequence
{
boolean arr[][];int n;
void bin(int a)
{
n=a;
int b= (int)Math.pow(2,n);
arr= new boolean[b][n];
int cnt=0;
for (int i=0;i=0;j--)
{
if (r%2==1)
arr[i][j]=true;
else
arr[i][j]=false;
r/=2;
}
}
}
void printSum(int a)
{
this.bin(a);
int s=0;int x=1;
int b= (int) Math.pow(2,a);
String str="";
for (int i=0;i

Program related to n C r (combinations).WAP to accept the value of n, starting value r1 and ending value r2. Print the s...
09/08/2015

Program related to n C r (combinations).
WAP to accept the value of n, starting value r1 and ending value r2. Print the sum from (n C r1) to (n C r2).

For ex:-
Input: n=9 , r1=2 and r2 = 6
Output: (9 C 2) + (9 C 3) + ......+ (9 C 5) + (9 C 6)
______________________________________________
import java.util.*;
public class SumComb
{
long fact(long n)
{
long f=1;
for(int i=1; i

A program that is tougher than the average ICSE program.WAP to accept an array of 7 integers from the user and display t...
27/03/2015

A program that is tougher than the average ICSE program.
WAP to accept an array of 7 integers from the user and display the elements in ascending/descending order without using any standard sorting technique.
Hint: You can use another array
====================================================

Source code:

/*
* Program to accept an array of integers and sort it using without using any general sorting technique
*
*/
import java.util.*;
class Sort2
{
static Scanner sc= new Scanner(System.in);
static int[] ar= new int[7];
void input()
{
for (int i=0;i

27/03/2015

Anyone who is opting for Computer Science in class 11 in CBSE or ISC?

20/03/2015

Important.
To resolve ambiguity between instance variables and parameters, "this" keyword is used. Static keyword is INCORRECT.

If you've written both, you will get the marks allotted.

18/03/2015

Tomorrow is the day..........Indian Council of Secondary Education (I.C.S.E.) Exam fro Computer Applications. Best of Luck to all our friends. We hope we could contribute something to your success..........

WAP in java to accept 10 number in a single-dimensional array.Print all the Magic numbers under a specific heading.A mag...
02/12/2014

WAP in java to accept 10 number in a single-dimensional array.
Print all the Magic numbers under a specific heading.

A magic number is a number in which the eventual sum of the digits is equal to 1
For example: 28=> 2+8= 10
10=> 1+0= 1
_________________________________________________
import java.util.*;
public class Magic
{
int sum(int x)
{
int ctr=0;
String s=Integer.toString(x);
for(int i=0; i9;x=sum(x)); //implementation of omitting expression
boolean flag=(x==1)?true:false;
return flag;
}
void main()
{
Scanner sc = new Scanner(System.in);
int[] arr=new int[10];
int[] mag=new int[10];
for(int i=0; i

A smith number is a composite number, the sum of whose digits is the sum ofthe digits of its prime factors obtained as a...
01/12/2014

A smith number is a composite number, the sum of whose digits is the sum of
the digits of its prime factors obtained as a result of prime factorization
(excluding 1). The first few such numbers are 4, 22, 27, 58, 85, 94, 121 …

Example :

666
Prime factors are 2, 3, 3 and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+(3+7) = 18
_______________________________________________

import java.util.*;
public class SmithNo
{
boolean PriFac(int x,int y)//to check for the prime factors
{
int ctr=0;
for(int i=1; i0; x/=10)
sum+=(x%10);
return sum;
}

void main()
{
System.out.print("Enter the Number: ");
int n=new Scanner(System.in).nextInt();
int temp=n; //backup of n
int s=Sum(n); //finding the sum
int k=0; //counter to compute the sum of prime factors
System.out.print("\nThe Prime Factors are: ");
for(int i=2; i9)
k+=Sum(i); // adding the sum of digits of multi-digit number
else
k+=i; //adding the factors
System.out.print(i+" ");
n=n/i; //updation, n has to be changed everytime
}
}
}
System.out.println();
System.out.print("\nThe Sum of "+temp+" is: "+s);
System.out.print("\nThe Sum of the Prime Factors of "+temp+" is: "+s);
System.out.println();
if(s==k)
System.out.println("\nSmith number!!");
else
System.out.println("\nNOT a Smith number!!");
}
}

Address

Kolkata

Website

Alerts

Be the first to know and let us send you an email when JAVA Programming for School posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share