Practice Exam
This commit is contained in:
33
Exams/PracticeExam2/src/practiceexam2/AgesOf3Daughters.java
Normal file
33
Exams/PracticeExam2/src/practiceexam2/AgesOf3Daughters.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 practiceexam2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class AgesOf3Daughters {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
int product = 0, sum;
|
||||
|
||||
while (product != -1) {
|
||||
System.out.print("Enter the product and then the sum of the ages of the 3 daughters or -1 to quit: ");
|
||||
product = input.nextInt();
|
||||
sum = input.nextInt();
|
||||
|
||||
if (product % 3 == 0) {
|
||||
|
||||
}
|
||||
else {
|
||||
System.out.println("Invalid input");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 practiceexam2;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class CharsToUnicodeWhile {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Define variables
|
||||
String toUnicode = "";
|
||||
|
||||
// Create scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
while (!toUnicode.toLowerCase().equals("q")) {
|
||||
// Prompt for input
|
||||
System.out.print("Enter a string of characters to convert them to UNICODE or Q/q to quit this program: ");
|
||||
toUnicode = input.next();
|
||||
if (toUnicode.toLowerCase().equals("q")) {
|
||||
break;
|
||||
}
|
||||
System.out.print(toUnicode + " in UNICODE is: ");
|
||||
for (int x = 0; x < toUnicode.length(); x++) {
|
||||
System.out.print(((int) toUnicode.charAt(x)) + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("Goodbye!");
|
||||
}
|
||||
}
|
21
Exams/PracticeExam2/src/practiceexam2/PracticeExam2.java
Normal file
21
Exams/PracticeExam2/src/practiceexam2/PracticeExam2.java
Normal file
@@ -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 practiceexam2;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PracticeExam2 {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// TODO code application logic here
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 practiceexam2;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class TransformToDOWhileLoops {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int i = 1;
|
||||
do {
|
||||
int j = 1;
|
||||
|
||||
do {
|
||||
|
||||
j += 2;
|
||||
if (i % 2 == 0) {
|
||||
continue;
|
||||
}
|
||||
System.out.print(j + " ");
|
||||
} while (j <= i + 1);
|
||||
System.out.println();
|
||||
++i;
|
||||
} while (i <= 9);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user