dobrien323's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
New Members
Active Posts:
10 (0.01 per day)
Joined:
12-October 12
Profile Views:
97
Last Active:
User is offline Oct 12 2012 07:58 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   dobrien323 has not set their status

Posts I've Made

  1. In Topic: Need Help Creating Code to Find Min and Max Numbers

    Posted 12 Oct 2012

    Do you have an example of how to cast an argument into an array? I haven't seen anything online, and it seems that I need arrays to do Sort functions for this new code on sorting from smallest to largest. I've only seen examples of casting pre-determined numbers into arrays. We can only use the arguments in the initial line of the command console for our code.

    For example, I would enter:
    java SortNumbers5 7 3 4 2 9

    Then, if the code worked properly, it would put them in order.
  2. In Topic: Need Help Creating Code to Find Min and Max Numbers

    Posted 12 Oct 2012

    I tried it that to clean up the code a little bit but it didn't work properly. I checked over it to make sure it was correct but couldn't seem to get it. I need to focus on my new code, SortNumbers now though. It's supposed to be a modification to MinMax5, but it prints the original input and then prints the numbers in order from smallest to largest.
  3. In Topic: Need Help Creating Code to Find Min and Max Numbers

    Posted 12 Oct 2012

    Works like a charm, despite being inefficient and a nightmare to a lot of advanced coders. :wink:

    public class MinMax5
    {
    	public static void main(String args[])
    	{
    	
    		double a = Double.parseDouble(args[0]);
    		double b = Double.parseDouble(args[1]);
    		double c = Double.parseDouble(args[2]);
    		double d = Double.parseDouble(args[3]);
    		double e = Double.parseDouble(args[4]);
    		double maxValue = a;
    		double minValue = a;
    		
    		if(a < 1 || a > 10 || b < 1 || b > 10 || c < 1 || c > 10 || d < 1 || d > 10 || e < 1 || e > 10)
    		{
    			System.out.println("Please enter numbers that are only between 1 and 10.");
    		}
    		
    		//start max value calculations
    		else if (a >= b && a >= c && a >= d && a >= e)
    		{
    			maxValue = a;
    			System.out.println(maxValue + " is the max.");
    		}
    		
    		else if (b >= a && b >= c && b >= d && b >= e)
    		{
    			maxValue = b;
    			System.out.println(maxValue + " is the max.");
    		}
    		
    		else if (c >= a && c >= b && c >= d && c >= e)
    		{
    			maxValue = c;
    			System.out.println(maxValue + " is the max.");
    		}
    		
    		else if (d >= a && d >= b && d >= c && d >= e)
    		{
    			maxValue = d;
    			System.out.println(maxValue + " is the max.");
    		}
    		
    		else if (e >= a && e >= b && e >= c && e >= d)
    		{
    			maxValue = e;
    			System.out.println(maxValue + " is the max.");
    		}
    		//end max value calculations
    		
    		//start min value calculations
    		if (a <= b && a <= c && a <= d && a <= e)
    		{
    			minValue = a;
    			System.out.println(minValue + " is the min.");
    		}
    		
    		else if (b <= a && b <= c && b <= d && b <= e)
    		{
    			minValue = b;
    			System.out.println(minValue + " is the min.");
    		}
    		
    		else if (c <= a && c <= b && c <= d && c <= e)
    		{
    			minValue = c;
    			System.out.println(minValue + " is the min.");
    		}
    		
    		else if (d <= a && d <= b && d <= c && b <= e)
    		{
    			minValue = d;
    			System.out.println(minValue + " is the min.");
    		}
    		
    		else if (e <= a && e <= b && e <= c && e <= d)
    		{
    			minValue = e;
    			System.out.println(minValue + " is the min.");
    		}
    		//end min value calculations
    	}
    }
    
    
  4. In Topic: Need Help Creating Code to Find Min and Max Numbers

    Posted 12 Oct 2012

    I cannot figure out how to make this thing work in a loop to save me. I figured it out with your last comment Kakerergodt! Thank you. This is due at midnight so maybe after that you could post an example of it with a loop? I'm sure it would help me on future assignments that need to use them, especially since I'm still extremely new at this. My next problem will be displaying the numbers in order from smallest to largest, which may require arrays and loops, which then I might definitely be stuck. I'll post my code that only needs to give me the max and min first, so you can see that I got it done.
  5. In Topic: Need Help Creating Code to Find Min and Max Numbers

    Posted 12 Oct 2012

    So I realized I need something to make the while loop stop, but I don't know what. It's not printing anything out anyways so I don't know where I'm wrong.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

dobrien323 hasn't added any friends yet.

Comments

dobrien323 has no profile comments yet. Why not say hello?