-
array assignmnet =(
hi
i'm saudi student
FRESHMEN IN MIS =)
i have an assignment and i can't get it =(
the Q IS
given the following array
int [] array={10,19,5,1,7};
write a java program using array to display its data graphically by plotting each numeric value as abar of asterisks (*) as shown in the diagram
element value histogram
0 10 **********
1 19 *******************
2 5 *****
3 1 *
4 7 *******
I Understand that i need to declare and use for loop
but i don't know how to convert the value to *
i want some help please =)
regard ..
-
Re: array assignmnet =(
can you show me what a for loop looks like.
-
Re: array assignmnet =(
for ( int i=0;i<array.length;i++)
this is what i learn =)
-
Re: array assignmnet =(
OK, so you can use another 'for' loop inside the array loop to print the correct number of '*' for each number. For each number in the array, you want to print the number itself, then the equivalent number of '*' (using the other 'for' loop). Think about how you typed it when you wrote that last message.
The purpose of computing is insight, not numbers...
R. Hamming
-
Re: array assignmnet =(
now, can you show me how to display a specific value inside of the array.
If you put those two things together, like dlorde said, you have the answer.
The biggest part of development you will find is not in the actual code. It never gets very complicated. It is in the thought process and understanding what you are trying to do and how to go about it.
-
Re: array assignmnet =(
try something using a for loop
when you have your variable declared just do print
Code:
for(int counter=0;counter<array.length;counter++){
System.out.print("*");
}
You could do something along those lines but since you are a student i suggest you try other ways of doing it.
--Alex