Practice Exam
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
|
||||
*/
|
||||
package practiceexamchapter6_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PracticeExamChapter6_CalebFontenot {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package practiceexamchapter6_calebfontenot.methods_test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Increment {
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
System.out.println("Before the call, x is " + x);
|
||||
increment(x);
|
||||
System.out.println("After the call, x is " + x);
|
||||
}
|
||||
|
||||
public static void increment(int n) {
|
||||
n++;
|
||||
System.out.println("n inside the method is " + n);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package practiceexamchapter6_calebfontenot.methods_test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
public static int maxOf3(int x, int y, int z)
|
||||
{
|
||||
if (x > y) {
|
||||
if (x > z) {
|
||||
return x;
|
||||
} else {
|
||||
return z;
|
||||
}
|
||||
} else if (y > z) {
|
||||
return y;
|
||||
} else {
|
||||
return z;
|
||||
}
|
||||
|
||||
// return -1;
|
||||
}
|
||||
|
||||
public static void printMessage(String message, int howManyTimes) {
|
||||
for (int i = 0; i < howManyTimes; ++i) {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//printMessage("the good, the bad, and the ugly", 100000);
|
||||
System.out.println(maxOf3(3, 2, 1));
|
||||
System.out.println(maxOf3(1, 2, 3));
|
||||
System.out.println(maxOf3(1, 1, 1));
|
||||
System.out.println(Methods.maxOf3(1, 2, 3));
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user