AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

# corejava-programming: Dinesh revenge

 Dinesh has been bullied enough all his life and now he seeks revenge. His first victim being Deepak, obviously! He found on e question to take revenge from deepak, but without knowing the answers of the question he would not be able to know whether deepak´s answers are correct or not. The question consists of two numbers, a and b, and the answer to it is the sum of digits of a^b (i.e - a raise to the power b). Help him to find the answers so that he can take revenge from deepak. (You should be able to write the solution for this problem in 25 minutes) Input: First line contains the number of test cases t. After that t lines follow each containing a pair of space separated integers i.e. a and b. Output: For each test case, you need to print the sum of digits in a^b. Sample Input : 2 2 10 3 3 Sample Output : 7 9 Explanation Consider the first test case. 2^10 = 1024 Now, 1 + 0 + 2 + 4 = 7 So, output for this test case is 7. corejava x 353programming x 168 Posted On : 2016-09-19 15:04:24.0 krish soni 530 5

 import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class DineshRevenge { public static void main(String[] args) { Scanner input=new Scanner(System.in); int t=input.nextInt(); List outputs= new ArrayList(); Double num; int sum=0; for(int i=1;i<=t;i++){ sum=0; num=Math.pow(input.nextInt(), input.nextInt()); outputs.add(num.intValue()); } for(Integer output:outputs){ for(char digit:output.toString().toCharArray()){ sum=sum+ Integer.valueOf(Character.toString(digit)); } System.out.println(sum); } outputs.clear(); outputs=null; } } Posted On : 2018-06-14 18:55:12 Satisfied : 1 Yes  2 No Garima Gupta 596129026817Reply This Thread 0

 import java.util.Scanner; public class DeepakRevenge { public static void main(String[] args) { Scanner input=new Scanner(System.in); int t=input.nextInt(); Double num; Integer intNum; int sum; for(int i=1;i<=t;i++){ sum=0; num=Math.pow(input.nextInt(), input.nextInt()); intNum=num.intValue(); for(char digit:intNum.toString().toCharArray()){ sum=sum+Integer.parseInt(Character.toString(digit)); } System.out.print(sum+" "); } } } Posted On : 2016-09-19 16:52:16 Satisfied : 1 Yes  6 No Rishi Kumar 523188222642Reply This Thread 2
Hey Can you pleas send the coding in Basic Java Format so that i can understand
25  5  0
Posted On :2016-09-20 14:48:49.0
This is basic java coding only, what is the challenge??
Rishi Kumar
523  1882  22642
Posted On :2016-09-21 22:15:31.0

 import java.util.Scanner; import java.lang.Math.*; public class Abslute { public static void main(String args[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); double a,b,power=0; for(int i=0;i 0) { rem = sum % 10; res = res + rem; sum = sum / 10; } // return; } System.out.print(res+" "); } } } find the below input specification.Let me know if this code is satisfied your specification or not. Input : 2 2 10 3 3 Output: 7 9 Posted On : 2016-09-20 22:56:25 Satisfied : 1 Yes  6 No 3
Not Satisfied ....my Test Cases are not cleared
25  5  0
Posted On :2016-09-21 15:02:19.0
Rishi Kumar
523  1882  22642
Posted On :2016-09-21 22:17:34.0
Can you provide clear Test cases for this .As per the given post your specifications are satisfied.
Posted On :2016-09-21 22:22:22.0