473,408 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

need help with arrays..

Yeah so I've been taking java programming as an elective course in school and I don't really understand how to use arrays and stuff. He's like flying through this chapter and I'm not picking it up at all. gah. I'm so stressed out. Now he assigned this program as a test grade:

"Design and implement an application that reads a set of values in the range 1 to 100 from the user and then creates a chart showing how often the values appeared. The chart should look like the one shown. It shows how many values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for every value entered. "

I have no idea where I'm going with this! And he wants us to use "0" to exit. I'm losing my mind. I've started this program over like 5 times. I'm not asking anyone to do this for me but i realllyyy need help with the array part.

the last time i asked for help somewhere everyone yelled at me. haha. please don't kill me.
May 16 '07 #1
3 2344
r035198x
13,262 8TB
Yeah so I've been taking java programming as an elective course in school and I don't really understand how to use arrays and stuff. He's like flying through this chapter and I'm not picking it up at all. gah. I'm so stressed out. Now he assigned this program as a test grade:

"Design and implement an application that reads a set of values in the range 1 to 100 from the user and then creates a chart showing how often the values appeared. The chart should look like the one shown. It shows how many values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for every value entered. "

I have no idea where I'm going with this! And he wants us to use "0" to exit. I'm losing my mind. I've started this program over like 5 times. I'm not asking anyone to do this for me but i realllyyy need help with the array part.

the last time i asked for help somewhere everyone yelled at me. haha. please don't kill me.
Post your best attempt at it so far and indicate the area you're having the most difficulty with.
May 16 '07 #2
JosAH
11,448 Expert 8TB
You can compare arrays with streets where a row of identical houses is located.
The name of the array is the name of the street. All houses have a number,
starting at zero and the house numbers increment by a step equal to one,
so house#0 house#1 house#2 ... etc. The numbers are analgous to house numbers.

In Java the houses have a type as all variables in Java have a type. Suppose
I have an array named 'count' with 100 'houses' or values:
Expand|Select|Wrap|Line Numbers
  1. int[] count= new int[100];
The 100 values are accessed as count[0], count[1], count[2] ... etc. up to
count[99] (check it out: 0, 1, 2 ... 99 are hundred numbers). Each value has
type 'int'.

Suppose I have a variable 'x' with a value in the range [0, 99]. I can use it to
access one of the values in the count array; the following example adds one to
the previous value in that variable ('house'):
Expand|Select|Wrap|Line Numbers
  1. count[x]= count[x]+1; // or: count[x]++ if you like
Normal variable have just a name; an array variabe has a name (a 'street name')
and an index number (a 'house number')

Does this help you out a bit?

kind regards,

Jos
May 16 '07 #3
rsrinivasan
221 100+
Hi,
I just did one java program what u ask. Instead of getting values from keyboard it gets 100 random value. If you want to get from keyboard use the class BufferedInputStream. Run it and ask any other Clarifacations.

<code removed; we don't spoonfeed posters>

Thanks,
Srinivasan r.
----------------------------------------------------------------------------------------------------
We appreciate your intentions to help; we really do. Spoonfeeding a poster
with complete running code doesn't help them out though. They won't learn
anything from it and they may be tempted to hand in your work as if it were
their own homework. That would be theft or plagiarism. Thank you for your
cooperation.

kind regards,

Jos
May 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dave A | last post by:
The following C code specifies the interface into a DLL. I need to access it from C#. How do I do declare it? I have done simple ones before but this particular API requires a pointer to a struct...
10
by: hack_tick | last post by:
hi there I was looking for some way to use bit field with Arrays something similar to struct Tmp { int iVar : 1; // each element of Aray having size as 1-BIT } it is possible ??
2
by: Xarky | last post by:
Hi, I have a two dimensional array as follows: double myArray = new double; Now I have a method which is returning double, which is of size 41. I need to put the data of the array returned...
3
by: Jeremy | last post by:
I have a predefined array that looks something like Private RemoveWords() As String = {"a", "b", "c" and I want to take an input string, and remove the words from the string that are in the...
3
by: triplejump24 | last post by:
i LOVE doing c++ programming, but i never can get myself started! Once i figure it out, its fun but anyways here it goes... Im given a file c:\temp\hwk8input.txt, which contains the records of the...
7
by: thegreatest21 | last post by:
Right, I am making a Tax Calculator and need an array to store the data that has been typed in when the user is prompted. However, being completely new to Java I am having some difficulty getting to...
0
by: Semajthewise | last post by:
Hi all... Here's the jist of what I want to do I want to read a string and place each object in that string into an array. for example texttbox1 has (3^4+5^3)+(4-5^2) I have never worked with...
5
by: enkidu72 | last post by:
Hello everybody , I have a problem with arrays ... I need to get some data from files in some directories . The names of the dirs are something like 12.12344 or 23.34441. Some contains one ,...
6
by: pereges | last post by:
Ok, I have some problem with arrays which i want to use for storing rays in my ray tracing project. please have a little patience to read. I need to fire rays from a a rectangular plane. The rays...
1
by: Alias09 | last post by:
I'm still a student, and I'm really having a hard time understanding how arrays of pointers and pointer arrays work. (dealing with C++) I'm trying to make a 2D Array with pointers, where the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.