The Artima Developer Community
Sponsored Link

Java Answers Forum
VERY new to Java

2 replies on 1 page. Most recent reply: Sep 5, 2005 2:39 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Christina

Posts: 1
Nickname: cc1969
Registered: Sep, 2005

VERY new to Java Posted: Sep 1, 2005 8:48 AM
Reply to this message Reply
Advertisement
Hey there. I am brand new to Java. I am taking a Java class right now as a requirement for my degree. I have no aspirations to become a programmer as I am quickly finding out it is NOT my forte'. I have a project this week that will probably be easy to you but I'm lost. We are working on Arrays this week. While I do understand the concept of Arrays I can't figure out how to incorporate it into my progThe objective to my project is this:
1. Prompt user for number of tests to be entered
2. Initialize an array to h old exactly the number ot Test Scores entered above
3. Main Method then calls inputData Method (Passing array as argument)
4. Main Method then calls outputData Method (Passing array as argument)

Here is what I have. Don't laugh..I know it's VERY wrong! ;)
/**
Java file featuring arrays.

*/
import java.util.*;

public class xxxTests

//*
User inputs test scores.
*//

{

public static void main(String[] args)

do
{

System.out.println("Enter Number of Tests Between 1 and 5:");
int n1;

Scanner Keyboard = new Scanner)System.in);
n1 = keyboard.nextInt();
if ((n1 < 0 ) || (n1 > 5 )
{
System.out.println("Invalid number entered, please try again:");
}
while ((n1 < 0) || (n1 > 5);

}
else
{

}
}




//Declare new array

double[] testscores = new double[5];

int index;
double sum, average;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter test scores:");
sum = 0
for (index = 0; index < 5; index++)
{

testscores[index] = keyboard.nextDouble();
sum = sum + testscores[index];
}

average = sum/5;

System.out.println("The average test score is:");
{

System.out.println("Hope this helped!");


}







ram. My objectives are this:


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: VERY new to Java Posted: Sep 1, 2005 10:59 PM
Reply to this message Reply
When you are posting your code, look at the little text box
with instructions titled: "Formatting Your Post".

Indent your code as per Java format:
public class MyClass{
       public void method1(){
 
       }
     
       public String method2(){
           return "thisIsAString";
       }
}

I don't know about the other cats on this forum, but
personally, I'll only respond to a legible post i.e.
I'll only respond to you post if you repost your code
in a more legible format. If its up before I knock
-off (6pm - free beer, Johannesburg time), then I guess
you're in luck. Else, Monday morning - unless some
very kind soul in this community wants to respond to
an eligible post. BTW, you're right it is quite a
simple project (probably 15 - 30 minutes of coding
at the most).

Regards,
Spike

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: VERY new to Java Posted: Sep 5, 2005 2:39 AM
Reply to this message Reply
Whe doing something with the array, replace '5' with 'n1'.

that should solve most of yourproblems.

Flat View: This topic has 2 replies on 1 page
Topic: how to use beans for file copy on another machine on LAN? Previous Topic   Next Topic Topic: hashcode()

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use