How to score ten scores in an array
Hello,
I hope someone can help me. I had to do the following assignment( i have most of it done just cant finish it off, question and source code below).
Question?
Write a Java program that asks the user to input the scores, as a percentage( e.g 87.4), of 10 students. The scores entered must be stored ina n array.
The programme must determine:
The lowest score and its equivalent grade (ie A,B,etc)
The highest " " " " "
The average score and its "
The bit i cant do is tie in the equivalent grade with the lowest highest and average score.
Code:
//Arrayofscores.java
//This programme asks the user to enter 5 exam scores and store them in an array
import java.text.*;
public class Arrayofscores
public static void main(String args[])
int [] scores = new int[10];
int smallest, highest,temp,total=0;
double average =0.0;
//ask the user to enter 10 scores
for (int i = 0;i<= scores.length-1;i++)
System.out.print("\n\nEnter Score " + (i+1) + ": ");
scores[i] = UserInput.getInt();
//find the lowest score
smallest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] < smallest)
smallest = scores;
System.out.println("\nThe lowest score is : " + smallest);
//find the highest score
highest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] > highest)
highest = scores[i];
System.out.println("\nThe highest score is : " + highest);
//find the average score
for (int i = 0; i<=scores.length-1;i++)
total = total + scores[i];
average = total/10.0;
System.out.println("\nThe average score is : " + average);
Any suggestions would be greatly appreciated!!
ok in the qriginal code i supplied there were no errors,i jst wanted to know how to tie in the grades into the code.
I used the advice and attempted the grade code with new method, so heres the full code again.
//Arrayofscores1.java
//This programme asks the user to enter 5 exam scores and store them in an array
import java.text.*;
public class Arrayofscores1
public static void main(String args[])
int [] scores = new int[10];
int smallest, highest,temp,total=0;
double average =0.0;
//ask the user to enter 10 scores
for (int i = 0;i<= scores.length-1;i++)
System.out.print("\n\nEnter Score " + (i+1) + ": ");
scores[i] = UserInput.getInt();
//find the lowest score
smallest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] < smallest)
smallest = scores;
System.out.println("\nThe lowest score is : " + smallest + grade);
//find the highest score
highest = scores[0];
for (int i = 1; i <= scores.length-1;i++)
if (scores[i] > highest)
highest = scores[i];
System.out.println("\nThe highest score is : " + highest);
//find the average score
for (int i = 0; i<=scores.length-1;i++)
total = total + scores[i];
average = total/10.0;
System.out.println("\nThe average score is : " + average);
public void getGrade(int n)
if(n > 85 && n<100) // print grade A
System.out.println("\nThis is an A grade");
else if(n > 70 && n < 85) // print grade B
System.out.println("\nThis is an B grade");
Im getting an error at the public static void getGrade that saids its an illegal start of expression.
Am i on the right track with this code
Similar Messages
-
How much score can i get with 3DMark 2001?
hey guys,
i have a MSI Geforce FX T128 (64 Bit) now how much score can i get with the default setting of 3D Mark 2003.
my old system pentium 3 733 Mhz with Geforce 2 MX 400 32 MB got about 1600 score in 3D Mark 2001 .
my current system is
2.40 Pentium 4 Prescott
MSI 865PE Platinium board
256 400 Mhz Kingston
Geforce FX 5200 T128 (64 Bit)well i tested my Geforce FX 5200 T128 (64) bit
i got the following result
in Running default resolution 1024*768 i got 5600 points
running in 800*600 resolution i got 7500 points
running in 640*480 resolution i got 8200 points
these resolution were in 32 bit color and i am using 4533 nvidia driver with it -
How to declare an expandable 2-dim Array
Hi,
How do I declare a 2-dim array that is can expandable with additional data?Look at this example (Catching the ideas of the other guis:
e.g. create a Class Object which represents a Row
class Row {
ArrayList list = new ArrayList(10); //ten columns
public Object getObject(int x) {
list.get(x);
public void setObject(Object o, int x) {
list.add(x, o);
Create an Table Object which is able to add your Rows-Objects
class Table {
ArrayList rows = new ArrayList();
public void addRow(Row row) {
rows.add(row);
public Row getRow(int x) {
return (Row) rows.get(x);
public int getNrOfRows() {
return rows.size();
after this, you can fill your Objects like this
Row row = new Row();
row.setObject(0, "James");
row.setObject(1, "Kirk");
row.setObject(2, "Captain);
Table table = new Table():
table.add(row);
Hope it helps a little bit -
On a form, using the value "image/*" for the accept attribute of the HTML input Element, how can I add .pdf to the array of pre-configured file types (.jpe, .jpg, .jpeg, .gif, .png, .bmp, .ico, .svg, .svgz, .tif, .tiff, .ai, .drw, .pct, .psp, .xcf, .psd, .raw)?
Say I wanted to add .gif, .jfif or .ico. I find this array limited, how can I add types to image?
<input type="file" name="file" accept="image/*" id="file" />
mimeTypes.rdf does not seem to allow this.''mimeTypes.rdf'' has nothing to do with web development. It's a file that stores your file handling preferences (e.g. if you want ZIP files automatically saved or opened).
You can't change the file types of the pre-defined content specifiers (audio/*, video/*, image/*), but you can specify additional MIME types. To add PDF to your above example,
<pre><nowiki><input type="file" name="file" accept="image/*,application/pdf" id="file" /></nowiki></pre>
For details, see
* [https://developer.mozilla.org/En/HTML/Element/Input developer.mozilla.org/En/HTML/Element/Input] -
Hello,
in my vi I have a chart with 5 Plots displaying measurement data.
The user should be able to save all the history data from the chart at anytime. (e.g. the user watches the chart and some event happens, then he presses a "save"-button)
I know, that I can read out the history data with a property node. That is not the problem. The problem is, how do I handle the data? The type of the history data is a 1-D array of cluster of 5 elements.
I have to convert that data somehow into a 2 D-array of numbers or strings, so that I can easily save it in a text-file.
How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers?
I use LabVIEW 7.1
Johannes
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
Solved!
Go to Solution.Gerd,
thank you for the quick response and the easy solution.
Look what I did in the meantime. I solved the problem too, but muuuch more complicate :-)
And I have converted the numbers to strings, so that I can easily write them into a spreasheet file.
Johannes
Message Edited by johanneshoer on 04-28-2009 10:39 AM
Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
Attachments:
SaveChartHistory.JPG 57 KB
SaveChartHistory.JPG 57 KB -
How to extract every component in an array?
Hello everyone!
Do you know how to extract every component from an array field?
For example:
The following is the defination of a table:
CREATE TABLE test (
id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape MDSYS.SDO_GEOMETRY
And then I insert a new record:
INSERT INTO test VALUES(
1,'first',
MDSYS.SDO_GEOMETRY(
2003,
NULL,
NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
MDSYS.SDO_ORDINATE_ARRAY(1,1, 5,7)
The Question is I want to read the every component (for example 1,1,5,7) in the sdo_ordinate_array one by one. Who knows how to write the SQL?
I have tried "select a.shape.sdo_ordinates(1) from test a". But it can't work.
Thank you very much!One solution is to read each ordinate from a cursor ina SQL block. Here is an example:
set serveroutput on
SET serveroutput on SIZE 1000000
set concat on
DEFINE layername = 'LAYER';
DEFINE geomcolname = 'GEOM';
DECLARE
id varchar2(10);
longitude number;
latitude number;
logmile number;
i number;
theLayer varchar2(32);
theGeomCol varchar2(32);
BEGIN
FOR rec IN (SELECT ROWID, id, &geomcolname FROM &layername ) LOOP
id := rec.id;
i := 1;
while i < rec.geom.sdo_ordinates.count loop
longitude:=rec.geom.sdo_ordinates(i);
latitude:=rec.geom.sdo_ordinates(i+1);
logmile:=rec.geom.sdo_ordinates(i+2);
dbms_output.put_line(id || ',' || longitude || ',' || latitude || ',' || logmile);
i := i + 3;
end loop;
END LOOP;
commit;
END;
Maybe that will help.
Dave
David R. Miller
Michael Baker Jr., Inc.
3601 Eisenhower Avenue
Alexandria, VA 22314
[email protected]
www.mbakercorp.com -
How to store logical operator in an array in java
how to store logical operator in an array in java.
Array should not be String type if i pass an element of that array it should be considered as logical operatormy exact requirment is like this, i need some logic
to convert string like this "2 Equals 3 AND 4 greater
than 7" to condition like this
2 == 3 && 4 >7 which i can pass to if
condition.So you want to create an expression parser?
No need for something as ugly as what you think you need, a simple nested conditional will do it for just the few logical operations. -
How can I create a variable size array?
How can I create a variable size array?
ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
Anyway, the answer to your question is, of course:
Vector v = new Vector();(But you should probably use ArrayList instead of Vector.) -
How to delete an element in an array...(simple way)
hi,
Newbie here... please help how to delete an element in an array list?
there are alot of codes but they're complicated for a newbie like me..
(simple codes would be better ..:) thank you...makk_88 wrote:
since u want the simple method.....
just overrite the position of the element that need to be deleted with the next element in the array..
by doing this, element need to be deleted will not be accessibe..
i think u got..what i'm saying.
thnx..Mak,
Say we wish to delete the second element of an array a[1]. Do you really believe that a[1] = a[2] somehow magically deletes a[1]? I really don't think so Tim.
Two eggs, minus 1, equals two eggs? Interesting theory, but I think you're probably wrong.
*@OP:* My advise is just use an ArrayList.
Cheers. Keith. -
How to store (non-persistent) multiple float[] arrays.
Hi;
In a situation where an object needs to store multiple float arrays, how can I use a 2 dimensional array to store them? I can't use a collection since an array is a primitive.
I would use a 2 dimensional array, but my keys to get/set these arrays are ints. So I cant do a "int i[][]", nor a "float f[][]".
Any ideas?
Thanks;
-natYou could make a Map (such as HashMap) with an
Integer (java.lang.Integer) key and a "int []" or "float []" as a value (an array is an Object, so can be put as a value).You kid me not! I need to review my basics.
I simply didn't know that an array of primitives can be stored as a value in a map.
Thank you!
-nat -
How can I inverse the Split 1D Array by recombining the splitting array?
How can I inverse the Split 1D Array by recombining the splitting array? i.e I have two boolean arrays A and B, and I want them in one boolean array: A array elements followed by B elements (NOT Interleaving)
Thank you
Solved!
Go to Solution.Thank you Marcus_Körner , GerdW and thoult for your assistance.
Sorry I am using Labview 2013, so I saved it in ver 2010 format, and I uploaded a photo for the circuit.
Attachments:
Packets.vi 8 KB
Untitled.png 5 KB -
How to bind bar chart(columns) to array list object in c# win form
how to bind bar chart(columns) to array list object in c#win form
Hi Ramesh,
Did you want to bind list object to bar chart? I made a simple code to achieve binding list to bar chart.
public partial class Form0210 : Form
public Form0210()
InitializeComponent();
private void Form0210_Load(object sender, EventArgs e)
BindData();
public void BindData()
List<int> yValues = new List<int>(new int[] { 20, 30, 10, 90, 50 });
List<string> xValues = new List<string>(new string[] { "1:00", "2:00", "3:00", "4:00", "5:00" });
chart1.Series[0].Points.DataBindXY(xValues, yValues);
The links below might be useful to you:
# Data Binding Microsoft Chart Control
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
# Series and Data Points (Chart Controls)
https://msdn.microsoft.com/en-us/library/vstudio/dd456769(v=vs.100).aspx
In addition, if I misunderstood you, please share us more information about your issue.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
How do i change 2 row of array into waveform with delta time and time
Hello,
How do i change 2 row of array into waveform with delta time and time
so the waveform graph will display two waveform,
waveform, not cluster =]
and how to extract 1d array from waveform?Hi AxE,
Here is an example VI, that do what You asked for.
Both requests.
Hope it Helps...
Attachments:
2D_to_Waveform.vi 75 KB -
How to add gaussian white noise to array of one's and negative one's ?
how to add gaussian white noise to array of one's and negative one's ?
Solved!
Go to Solution.Is it this that your are trying to accomplish:
TO:
Here's the code to do that.
Michel -
How to convert a waveform signal into array of complex numbers
How to convert a waveform signal into array of complex numbers.
Hi Chaks,
try this:
(Get Waveform components, convert to complex DBL)
Message Edited by GerdW on 01-28-2008 09:23 AM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
ToCDB.png 1 KB -
How to show the elements of an array?
How to show the elements of an array, when the array size changes every loop?
It's possible to use node property?
thanks
Vicens
Win XP/ LV7.1
Attachments:
show elements.PNG 184 KBBasically it is (at least in LV8.0). There is a property "Number of Rows" which sets the number of visible rows. If your 1D array is placed horizontally, use "Number of Columns".
Using LV8.0
Don't be afraid to rate a good answer...
Maybe you are looking for
-
Copyright Question - two ipods with iTunes Music
I apologize if this was answered in an FAQ or some other obvious place. I have googled around and can't seem to find the answer. I have just purchased my wife an iPod for Christmas, making us a two iPod household (including mine). Until this point my
-
TIme Machine backing up an External Drive
hello a problem that is really vexing me I had a 500gb ext hardrive for my itunes and then a 1TB harddrive for my time machine, both plugged in at all times, to my macbook due to the iTunes drive getting full I got a new 1TB drive for that (not the s
-
ScreenSaver Still Stays On After Upgrading to 10.6.7
Hi, I manage a lab of 88 computers at Santa Clara University. After upgrading from 10.5.8 to version 10.6.7 the screensaver stays on after I have disabled it in the system preferences. I've tried to delete the preference files in both the user profil
-
Can Apple do Something about his or can I?
I have recently been having trouble with the alarm capabilities on my iPhone. When I attempt to set a simple alarm, and if anything comes before that time(i.e a text or a missed call) my alarm will not go off until I unlock my iPhone to look at whate
-
Hi. We have a problem with the connection of several CPEs (non-cisco). these CPEs sends a PADR with a size of 129 bytes, then our concentrator (7200) doesn't accept the connection: Jan 7 09:27:25.325: [818]PPPoE 397: Service request sent to SSS Jan