Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 14 Online
OpenStudy (anonymous):

Hi, to begin I am a complete novice so yes I know its not perfect by any means, please excuse/critique my mistakes :) 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!

OpenStudy (siberman):

Might want to post your code mate.

OpenStudy (anonymous):

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 = 0; int index; do{ int[] statsArray = new int[arrayLength]; arrayLength =keyboard.nextInt(); if ((!(arrayLength == 0)) && (arrayLength > 0)) { positiveEntry = true; } if (arrayLength < 0) positiveEntry = false; System.out.println("Error! Numeric entry is not within parameters. Please enter only non-negative integers"); positiveEntry = true; arrayLength =keyboard.nextInt(); for( index = 0; index < statsArray.length; index++) arrayLength =keyboard.nextInt(); System.out.println("Your array will contain " + arrayLength + " numeric entries. Input each one at a time below"); else {System.out.println("Invalid entry, please enter a positive whole number:"); arrayLength =keyboard.nextInt(); }} while (arrayLength < 0); }}

OpenStudy (anonymous):

thought i posted the code before but i guess not thank u for the heads up! I know the code i just posted has errors...I forgot braces before the else when moving something around my apologies...as of right now it is catching if user enters zero outputting the error but when a positive number is entered it is not re-prompting for input...but however that's not my biggest concern/issue its that I don't know how to have the program stop when negative is entered, not use that number in calculations (2nd half of assignment) and then cont. of course and store numbers that satisfy the requirements in an array...done some research was thinking/leaning towards an array list but would appreciate some guidance :) thank you!

OpenStudy (siberman):

This forum is for people who are studying Introduction to Computer Science through MIT open course ware, which teaches Python. Someone may be able to answer your question, but you'll probably have better luck if you go to a general computer programming forum. good luck.

OpenStudy (anonymous):

Oh, so this is only for Python specifically? I'll keep that in mind from now on. Probably saved me a bit of time, thanks!

OpenStudy (anonymous):

no its not for python..its for java sorry for the misunderstanding this link was provided by someone on a help forum...this whole assignment is my first time posting for help and on the other site dude left a rude comment and this link and said to post here...I should have paid attention and read the purpose/who this site is designated for but I didnt my mistake...if you still want to help, I could use some and greatly appreciate it :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!