__This program is for finding automorphic number ....but it is not working on bluej.....plz tell what's incorrect??__ import java.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("enter number"); int n=input.nextInt(); int r;int s=0; int sq=n*n; int t=sq; int c=1;int o=0; while(t!=0) { r=t%10; o++; t=t/10; } int counter=0; for(r=sq%10;sq!=0;sq=sq/10) { counter++; s=s+r*c; c=c*10; if(s==n) { System.out.println("auto"); break; } else if(counter==o) System.out.println("not"); } } } |
|
asked by Fire Bird (firebird) 6 years ago | |
2 |
Write a program to accept numbers in a single dimensional array of size ‘N’. Create another string array of size ‘N-1’ to accept valid mathematical symbols like (+, -, /, %, *…). Calculate and display the result by performing the operations by using the symbols stored in the string array on the values stored in the integer array. Example: int Arr[]={1,2,3,4} String Sym[]={“+”,”/”,"*”} The result is 4. ((1+2)/3)*4 HELP!! |
|
asked by Shreya Bhagat (hermione02) 6 years ago | |
1 |
Provide me with some very hard program for a good mental workout and practice. Please , I am providing u with one and u too please provide me some: Take a 10 elements integer array. Accept numbers in it from the user which can be negative or positive in the cells. Now shift the positive numbers on the left side and the negative numbers on the right side in the same sequence as they are been provided in the array by the user.] Now print the modified array. Sample Input:{1,-1,2,-2,3,-3,4,-4,5,-5} Sample Output:{1,2,3,4,5,-1,-2,-3,-4,-5} (Note that the output can not have the sequence of the positive or negative numbers altered like the output cannot be {2,3,1,5,4,-1,-5,-3,-2,-4}) To make things a bit tough(the way my teacher made it) only 1 array can be used in the entire program. No problem as it will never come at least in ICSE boards. Share your tough program problems too please |
|
asked by Rishi dey chowdhury (rishidc) 6 years ago | |
4 | |