AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

# corejava-programming: Miracle Cubes-30 min

 Miracle Cube are numbers whose cube root is equal to the sum of its own digits. Write a program which will print the number of distinct non miracle cubes in the series of n numbers(where n is a user specified integer such that 0 lessthan n and n less than equals 50) Input Specification: ----------------------------------- First input n will be an integer number which the user is expected to provide(where 0

## Answers

 import java.util.Scanner; public class MiracleCubes { public static void main(String[] args) { Scanner input=new Scanner(System.in); int total=input.nextInt(); int count=0; for(int i=0;i
Comments
Your Code is not cleared my test cases because there is no n value and no command
Posted On :2016-10-28 11:41:22.0
Leave a Comment
can you please provide the code that is asked in question situation
Posted On :2016-10-28 11:42:21.0
Leave a Comment
Hi Akash,
Please try below code, If still if you face any problem, give me the test case, I´ll check and revert you back.

import java.util.Scanner;

public class MiracleCubes {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int total=input.nextInt();
int count=0;
if(total>0 && total<=50){
for(int i=0;i<total;i++){
if(isMiracleCube(input.nextInt())){
count++;
}
}
System.out.println(count);
}else{
System.out.println("Invalid Input");
}
}
public static boolean isMiracleCube(Integer num){
double cbrt=Math.cbrt(num);
double total=0;
for(int i=0;i<num.toString().length();i++){
total=total+Double.parseDouble(Character.toString(num.toString().charAt(i)));
}
if(cbrt==total)
return true;
else
return false;
}
}
Posted On :2016-10-29 22:55:18.0
Leave a Comment

 import java.util.Scanner; import java.lang.*; class miracle { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int c=0,m=0; if(n>0 && n<=50) { int []a=new int[n]; for(int i=0;i0 && Math.pow(a[i],3)0) { System.out.println(c); } } else{ System.out.print("Invalid input"); } } } Posted On : 2016-10-31 13:01:57 Satisfied : 0 Yes  2 No 3 Comments
two cases are passed but 3rd case is not passed still getting a problem...can you please create n as an array and again write the new code by using n as an array
Posted On :2016-10-31 14:12:11.0
Leave a Comment
It´s not about we have to take N as an array. Please comment the test case which is failing.
Posted On :2016-11-02 19:49:37.0
Leave a Comment

Post Answer
Please Login First to Post Answer: Login

 Answer: