Export Exam
This commit is contained in:
parent
4babe809d4
commit
780c56095f
1
.gitignore
vendored
1
.gitignore
vendored
@ -171,3 +171,4 @@
|
||||
/Semester 3/Assignments/SerialPogAnt/build/
|
||||
/Semester 3/GenericStack/target/
|
||||
/Semester 3/Assignments/lab6_generics_CalebFontenot/target/
|
||||
/Semester 3/Exams/Projects/ProgramingExam1_CalebFontenot/target/
|
||||
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.mycompany.programingexam1_calebfontenot</groupId>
|
||||
<artifactId>ProgramingExam1_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<exec.mainClass>com.mycompany.programingexam1_calebfontenot.ProgramingExam1_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
|
||||
package com.mycompany.programingexam1_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class ProgramingExam1_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 com.mycompany.programingexam1_calebfontenot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class Question2 {
|
||||
private static int posInArray = 0;
|
||||
public static void printArrayList(List<Integer> list) {
|
||||
// Base case
|
||||
if (posInArray == list.size()) {
|
||||
posInArray = 0;
|
||||
return;
|
||||
}
|
||||
System.out.println(list.get(posInArray++));
|
||||
printArrayList(list);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
ArrayList<Integer> l = new ArrayList();
|
||||
l.add(10); l.add(20);
|
||||
printArrayList(l);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 com.mycompany.programingexam1_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class Question3 {
|
||||
public static int countDigits(int x) {
|
||||
return countDigits(x, 0);
|
||||
}
|
||||
|
||||
public static int countDigits(int x, int index) {
|
||||
// Base case
|
||||
if (x == 0) {
|
||||
return index;
|
||||
}
|
||||
return countDigits(x / 10, ++index);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
System.out.println(countDigits(1));
|
||||
System.out.println(countDigits(111111));
|
||||
System.out.println(countDigits(20));
|
||||
System.out.println(countDigits(100));
|
||||
System.out.println(countDigits(1231));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 com.mycompany.programingexam1_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ar114
|
||||
*/
|
||||
public class Question4 {
|
||||
|
||||
public static void print3dArrayR(int[][][] arr, int i, int j, int k) {
|
||||
if (i >= arr[k][j].length) {
|
||||
i = 0;
|
||||
++j;
|
||||
System.out.println();
|
||||
}
|
||||
if (j >= arr[k].length) {
|
||||
j = 0;
|
||||
++k;
|
||||
System.out.println();
|
||||
}
|
||||
// Base case
|
||||
if (k >= arr.length) {
|
||||
//k = 0;
|
||||
return;
|
||||
}
|
||||
System.out.print(arr[k][j][i] + " ");
|
||||
|
||||
//System.out.println("array: " + i + " " + j + " " + k);
|
||||
print3dArrayR(arr, ++i, j, k);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[][][] arr = {
|
||||
{
|
||||
{1, 2, 3, 4},
|
||||
{5, 8},
|
||||
{9, 10, 11, 12, 13, 14}
|
||||
},
|
||||
{
|
||||
{13, 16},
|
||||
{17, 18, 19, 20},
|
||||
{21, 22, 24},
|
||||
{21, 22, 23, 24, 35, 26, 27}
|
||||
}
|
||||
};
|
||||
//System.out.println(arr[0][0][1]);
|
||||
print3dArrayR(arr, 0, 0, 0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user