Results 1 to 2 of 2
  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2012

    Exclamation PLEASE HELP <--Beginner! project due @ midnight!

    Hi, to begin I am a complete novice so yes I know its not perfect by any means and criticism I appreciate but please don't be too hard on me So the assignment I would like to complete is specified here:
    a. Display your name to the screen and some info you get from the user’s computer and the date the program is executed. Use the same method you used for your previous assignment. (DONE)
    b. Ask user for the number of nonnegative whole numbers to be entered, create an array of that length, and then ask the user to enter the numbers one at a time. (DONE)
    c. Your program will store the numbers in an array. (DOnE i think!)

    d. If the input number is negative. (DONT KNOW/UNDERSTAND)
    • You ignore the number (do not accept it nor use it in your calculations)
    • You give user a warning that an illegal negative number has entered.
    • Go back to your loop and ask for another input.

    **so i have researched and give me a little break this is an online class so I have to figure it out on my own and I have found that maybe I should store the number in an array list?! but how ever if I do that that would therefore make what I have done pointless and have to redo it?! I just need some guidance and hopefully as soon as possible?! THANK YOU! this is what I have so far:

    package mystatisticsdemo;
    import java.util.*;
    * @author Linette
    public class MyStatisticsDemo {

    * @param args the command line arguments
    public static void main(String[] args) {

    System.out.println("\t\t\t\tHello " + System.getProperty("user.name") + "!");
    String os = System.getProperty("os.name");
    String version = System.getProperty("os.version");
    System.out.println("\t\t I am running "+os+", version "+version);
    System.out.println("\tYour assignment was completed on " + (new Date()));

    System.out.println("\n\nPlease enter a non-negative whole number to "
    + "represent the length of your array:");

    boolean positiveEntry = false;
    Scanner keyboard = new Scanner(System.in);
    int arrayLength;

    arrayLength = keyboard.nextInt();
    if ((!(arrayLength == 0)) && (arrayLength > 0))
    positiveEntry = true;
    int[] statsArray = new int[arrayLength];
    System.out.println("Your array will contain " + statsArray.length +
    " numeric entries. Input each one at a time below");
    for(int index = 0; index < statsArray.length; index++)
    statsArray[index] = keyboard.nextInt();
    System.out.println("Invalid entry, please enter a positive whole number:");
    while (arrayLength <= 0);

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Adelaide, Australia

    Re: PLEASE HELP <--Beginner! project due @ midnight!

    Well to check whether a number is negative you might put something such as:

    if (number < 0){
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.