Assignment = More Fill-In Methods

Code

  /// Name: Sam Wilson
  /// Period: 6
  /// Program Name: Moar Fill In Methods
  /// File Name: fillin2.java lol
  /// Date Finished: 3/26/16
 
  
   import java.util.Scanner;
    
    public class fillin2
    {
    	public static void main( String[] args )
    	{
    		System.out.println("Here ya go.");
    
    		System.out.println();
    		System.out.println("Some random numbers, if you please: ");
    		int lo, hi, val1 = 999, val2 = 999;
    		lo = 1;
    		hi = 10;
    		val1 = superRand(lo, hi);
    		System.out.println("First: " + val1 );
            
    		val2 = superRand(hi, lo);
    		System.out.println("Second: " + val2 );
            
    		if ( val1 == val2 )
    			System.out.println("Hey!  They were the same!");
    		else
    			System.out.println("They were not the same.");
    
    		System.out.println();
    		System.out.print("More counting, but this time not by ones: ");
    		stepCount(2, 8, 2);
    		stepCount(10, 2, 2);
    
    		System.out.println();
    		System.out.println("Let's figure a project grade.");
    		int a=4,b=3,c=4,d=5,e=2,f=1, result=999;
    		result = projectGrade(a, b, c, d, e, f);
    		System.out.println("434521 -> " + result );
    
    		System.out.println();
    		System.out.print("Finally, some easy ones.");
    
    		String name = "WTF";
            name = getName();
    		System.out.println("Hi, " + name );
    
    		System.out.println();
    		System.out.println("Do you feel lucky, punk?");
    		crash();
    		System.out.println();
    	}
    
    	public static int superRand( int a, int b )
    	{
    		int c;
    
    		if ( a < b )
    			c = a + (int)(Math.random()*(b-a+1));
    		else if ( a > b )
    			c = b + (int)(Math.random()*(a-b+1));
    		else
    			c = a;
    
    		return c;
    	}
    
     	public static void stepCount( int first, int last, int step )
    	{
    		int x;
    
    		if ( first < last )
    		{
    			x = first;
    			while ( x <= last )
    			{
    				System.out.print(x + " ");
    				x = x + step;
    			}
    		}
    		else
    		{
    			x = first;
    			while ( x >= last )
    			{
    				System.out.print(x + " ");
    				x = x - step;
    			}
    		}
    	}
    
    	public static int projectGrade( int p1, int p2, int p3, int p4, int p5, int p6 )
    	{
    		int overall_grade;
    
    		overall_grade = p1 * 6;
    		overall_grade = overall_grade + ( p2 * 6 );
    		overall_grade = overall_grade + ( p3 * 4 );
    		overall_grade = overall_grade + ( p4 * 2 );
    		overall_grade = overall_grade + ( p5 * 1 );
    		overall_grade = overall_grade + ( p6 * 1 );
    
    		return overall_grade;
    	}
    
    	public static String getName()
    	{
    		Scanner keyboard = new Scanner(System.in);
    
    		String name;
    		System.out.print("Please enter your name: ");
    		name = keyboard.next();
    
    		return name;
    	}
    
    	public static void crash()
    	{
    		String magic_word;
    
    		if ( (int)(Math.random()*10) == 0 )
    		{
    			magic_word = "GREAT SUCESS";
    		}
    		else
    		{
    			magic_word = "NO";
    		}
    
    		System.out.print("you " + magic_word);
    	}
    }
      

    

Picture of the output

Assignment 31