# Thread: Problem with given program !!!

1. Senior Member Join Date
Dec 2016
Posts
103
Rep Power
0

## Problem with given program !!!

Hii i'm trying to make a program to find largest number but i'm puzzling in my logic i can't create an logic pease help!!!

thanks

<code>
import java.util.*;
class arra1
{
public static void main(String[] args)
{
int v=0;
Scanner in=new Scanner(System.in);
System.out.println("How much value you want to calculate");
int arr=in.nextInt();
int ar[] = new int[arr];
System.out.println("Enter"+arr +"values to calculate max value" );
for(int i=0;i<arr;i++)
{
ar[v]=in.nextInt(); //i can't understand why it takes v in ar. "ar[v]=in.nextInt(); "

}

for(int i=0;i<arr;i++) /** i caan't understand this logic what is happening here..
{
if(ar<ar[v])
ar=ar[v];
}

System.out.println("dcfvgb"+ ar[v]);

}
}
</code>

thanks  Reply With Quote

2. ## Re: Problem with given program !!!

i'm puzzling in my logic
Can you explain your logic in English to show the problems you are having?
What steps should the program take to find the largest number?
How would you do it if you were doing it manually?

Please use [] with the code tags, not <>  Reply With Quote

3. Senior Member Join Date
Dec 2016
Posts
103
Rep Power
0

## Re: Problem with given program !!! Originally Posted by vknehra10 Hii i'm trying to make a program to find largest number but i'm puzzling in my logic i can't create an logic pease help!!!

thanks

Java Code:
```import java.util.*;
class arra1
{
public static void main(String[] args)
{
int v=0;
Scanner  in=new Scanner(System.in);
System.out.println("How much value you want to calculate");
int arr=in.nextInt();
int ar[] = new int[arr];
System.out.println("Enter"+arr +"values to calculate max value" );
for(int i=0;i<arr;i++)
{
ar[v]=in.nextInt();                                 //i can't understand why it takes v in ar. "ar[v]=in.nextInt(); "

}

for(int i=0;i<arr;i++)                                     /** i caan't understand this logic what is happening here..
{
if(ar<ar[v])
ar=ar[v];
}

System.out.println("dcfvgb"+ ar[v]);

}
}```
thanks

actually i don'tknow ....also i just want to make a program to find largest number with array but i am unable to make any logic..  Reply With Quote

4. ## Re: Problem with given program !!!

i just want to make a program to find largest number with array
Before writing any code you should work on making a list of the steps the program needs to take to solve the problem.
How would you do in manually if you have a stack of playing cards and wanted to find the card with the highest value?
What steps would you take to search the cards?  Reply With Quote

5. Senior Member Join Date
Dec 2016
Posts
103
Rep Power
0

## Re: Problem with given program !!!

i will check all the cards....

is there any option to chat with you....  Reply With Quote

6. ## Re: Problem with given program !!!

i will check all the cards
Yes that would be required. What decision would you make when you look at each card?
You need to describe all the steps as simply as possible for the computer.
Now get the second card. What decision would you make?
Continue with the rest of the cards.  Reply With Quote

array, array error, array example 