Practice Exam

This commit is contained in:
2022-11-02 09:15:54 -05:00
parent d32ce7930a
commit c879dde19e
27 changed files with 4358 additions and 0 deletions

View 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");
}
}
}
}

View File

@@ -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!");
}
}

View 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
}
}

View File

@@ -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);
}
}