Assignment = Fill-In Methods
Code
/// Name: Sam Wilson
/// Period: 6
/// Program Name: Fill-In Methods
/// File Name: fillin.java lol
/// Date Finished: 3/26/16
public class fillin
{
public static void main( String[] args )
{
System.out.println("Watch as we demonstrate functions.");
System.out.println();
System.out.println("I'm going to get a random character from A-Z");
System.out.println("The character is: " + randChar() );
System.out.println();
System.out.println("let's count from -10 to 10");
int start, stop;
start = -10;
stop = 10;
counter(start, stop);
System.out.println("Pretty good eh?");
System.out.println();
System.out.println("Now we take the absolute value of a number.");
int x;
x = -10;
System.out.println("|" + x + "| = " + abso(x) );
System.out.println();
System.out.println("That's all. This program has been brought to you by:");
credits();
}
public static void credits()
{
System.out.println();
System.out.println("programmed by Joshua Davis");
System.out.println("modified by Sam Wilson");
System.out.print("This code is Pretty Damn OP Son ");
System.out.println("Do with it as you wish ;)");
}
public static char randChar()
{
int numval;
char charval;
numval = (int)(Math.random()*26);
charval = (char) ('A' + numval);
return charval;
}
public static void counter( int start, int stop )
{
while ( start <= stop )
{
System.out.print( start + " " );
start = start + 1;
}
}
public static int abso( int x )
{
int absval;
if ( x < 0 )
absval = -x;
else
absval = x;
return absval;
}
}
Picture of the output