i cant really understand this concept
i have this code...
public static int A(int m, int n){
if(m == 0) return n+1;
else if(m > 0 && n ==0) return A(m-1,1);
else if(m > 0 && n > 0) return...
Type: Posts; User: gonfreecks
i cant really understand this concept
i have this code...
public static int A(int m, int n){
if(m == 0) return n+1;
else if(m > 0 && n ==0) return A(m-1,1);
else if(m > 0 && n > 0) return...
that helped thank you :)
public class Recursion {
public static double power(double a, int n){
double tmp,result,answer;
if(n % 2 == 0){
tmp = power(a, n-1);
result = (tmp*(n/2));
...
i am designing this my circle class
i. It should contain three private doubles for x, y and radius.
ii. A constructor that accepts three double parameters for x, y, and radius.
iii. A...
import java.util.Scanner;
import java.io.*;
public class Part5{
public static int [][] getSubMat(int [][] data, int row, int col, int width, int height){
int [][] newMat = new int...
yeah but my homework specifically said that the data should be stored in the reference variable called mat and the size of the method should be the value returned
uhh you said to return the array...
i already tried that code
public static void printMat(int [][] mat, int size){
for ( int i = 0; i < mat.length; i++ ){
for ( int j = 0; j < mat[i].length; j++ ){
...
public static int loadMat(int [][] mat) throws Exception{
int size, row, col = 0, num;
Scanner input = new Scanner(System.in);
System.out.print("Enter the size of the...
nevermind already done it
for (i = 0 ; i < list.length ; i++){
if (list[i] == list2[0])
location = i;
break;
ok i have that code which locates a single number but i cant figure out how to continue...
o ok overlooked the equal sign sorry....
and thank you.. and uhm 1 more thing, how can i align the arrays?
is there a command like printf for arrays?
thanks so much its working now but i dont get why an error keeps popping..
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at lab8.Arrays.main(Arrays.java:35)
...
public class Arrays {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x, y =0;
int [] list;
list = new int [10];
int [] list2;
list2 = new...
its still kinda long though can im thinking of using a for loop for this
ok we just started arrays yesterday and made us do a program..
this basically prints 2 lists of arrays that has 10 blocks with random numbers in each block (1-99)
it works but does anyone know how...
it works my calculation works fine but when i run the program it doesnt come close to the value of pi which is 3.14 sumthing only up to 2.7 sumthing..
am i doing the calculation wrong?
i did......
double denom = 3;
double pi;
double x = -1;
int i;
double pi2 =0;
double denom2 = 0;
double pi3 = 0;
pi = 4*(1-((double)1/denom));
pi2 = pi;
int num;
int i = 2;
int j;
String yn;
do {
System.out.print("Enter number : ");
yeah nevermind i got it already thank you anyways.... :)
double denom = 3;
double pi;
double x = -1;
int i;
for (i=1 ; i<=30000 ; i++){
pi = 4*(1-((double)1/denom));
x = x*-1;
double denom = 3;
double pi;
double x = -1;
int i;
pi = 4*(1-((double)1/denom));
for (i=1 ; i<=30000 ; i++){
x = x*-1;
denom = (double)x*(denom+2);
and the posts of penguin is so advanced we havent even tackled some yet... but thanks for the effort though
and the 1st code you posted was an infinite loop :)
oh yeah my bad it runs 2 2 2 3 5 but if i run 150 it only runs 2 3 5 while it needs to output 2 3 5 5..
thanks for the help
public class Factor {
public static void main(String[] args){
Scanner input=new Scanner (System.in);
String yn;
int number;
int current;
String output = "";
...
uhh ok nevermind i got it thanks :)