-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import java.util.Scanner; | ||
import java.util.Vector; | ||
|
||
public class DecemberFourth { | ||
Vector<Character> v = new Vector<Character>(); | ||
Scanner in = new Scanner(System.in); | ||
|
||
public DecemberFourth() { | ||
v.add('a'); | ||
v.add('e'); | ||
v.add('i'); | ||
v.add('o'); | ||
v.add('u'); | ||
v.add('y'); | ||
} | ||
|
||
public void output() { | ||
System.out.print("Enter a word: "); | ||
String word = in.next(); | ||
int count = 0; | ||
|
||
for (Character c : word.toCharArray()) { | ||
if (v.contains(c)) { | ||
count++; | ||
} | ||
} | ||
|
||
System.out.println("There are " + count + " vowels in " + word); | ||
} | ||
|
||
public static void main(String[] args) { | ||
DecemberFourth ds = new DecemberFourth(); | ||
ds.output(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import java.util.Scanner; | ||
|
||
public class DecemberFourth2 { | ||
public static void main(String[] args) { | ||
Scanner in = new Scanner(System.in); | ||
System.out.print("Enter a word: "); | ||
String word = in.next(); | ||
for (int i = 0; i < word.length(); i++) { | ||
for (int j = i; j < word.length(); j++) { | ||
System.out.println(word.substring(i, j + 1)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
public class holiday { | ||
static String dayStr; | ||
static String intro = "On the twelfth day of Christmas, my true love gave to me "; | ||
static String day1 = "a partridge in a pear tree."; | ||
static String day2 = "two turtle doves, and "; | ||
static String day3 = "three French hens, "; | ||
static String day4 = "four calling birds, "; | ||
static String day5 = "five golden rings, "; | ||
static String day6 = "six geese a-laying, "; | ||
static String day7 = "seven swans a-swimming, "; | ||
static String day8 = "eight maids a-milking, "; | ||
static String day9 = "nine ladies dancing, "; | ||
static String day10 = "ten lords a-leaping, "; | ||
static String day11 = "eleven pipers piping, "; | ||
static String day12 = "twelve drummers drumming, "; | ||
|
||
public static void main(String[] args) { | ||
System.out.println(); | ||
System.out.println(); | ||
for (int i = 1; i <= 12; i++) { | ||
whatDay(i); | ||
System.out.println(day(i)); | ||
System.out.println(); | ||
} | ||
} | ||
public static String day(int day) { | ||
switch (day) { | ||
case 1: | ||
return day1; | ||
case 2: | ||
return day2 + day1; | ||
case 3: | ||
return day3 + day2 + day1; | ||
case 4: | ||
return day4 + day3 + day2 + day1; | ||
case 5: | ||
return day5 + day4 + day3 + day2 + day1; | ||
case 6: | ||
return day6 + day5 + day4 + day3 + day2 + day1; | ||
case 7: | ||
return day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
case 8: | ||
return day8 + day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
case 9: | ||
return day9 + day8 + day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
case 10: | ||
return day10 + day9 + day8 + day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
case 11: | ||
return day11 + day10 + day9 + day8 + day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
case 12: | ||
return day12 + day11 + day10 + day9 + day8 + day7 + day6 + day5 + day4 + day3 + day2 + day1; | ||
default: | ||
break; | ||
} | ||
return "Error"; | ||
} | ||
|
||
public static void whatDay(int day) { | ||
switch (day) { | ||
case 1: | ||
dayStr = "first"; | ||
break; | ||
case 2: | ||
dayStr = "second"; | ||
break; | ||
case 3: | ||
dayStr = "third"; | ||
break; | ||
case 4: | ||
dayStr = "fourth"; | ||
break; | ||
case 5: | ||
dayStr = "fifth"; | ||
break; | ||
case 6: | ||
dayStr = "sixth"; | ||
break; | ||
case 7: | ||
dayStr = "seventh"; | ||
break; | ||
case 8: | ||
dayStr = "eighth"; | ||
break; | ||
case 9: | ||
dayStr = "ninth"; | ||
break; | ||
case 10: | ||
dayStr = "tenth"; | ||
break; | ||
case 11: | ||
dayStr = "eleventh"; | ||
break; | ||
case 12: | ||
dayStr = "twelfth"; | ||
break; | ||
} | ||
System.out.print("On the " + dayStr + " day of Christmas, my true love gave to me "); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public class nov30 { | ||
public static void main(String[] args) { | ||
for (int i = 1; i <= 10; i++) { | ||
for (int j = 1; j <= 10; j++) { | ||
System.out.print(i * j + "\t"); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import java.util.Scanner; | ||
|
||
public class thing { | ||
static long timeout = 500; | ||
static int num = 243079824; | ||
public static void main(String[] args) { | ||
// a | ||
System.out.println("\na"); | ||
int sum = 0; | ||
for (int i = 2; i <= 100; i += 2) { | ||
sum += i; | ||
} | ||
System.out.println(sum); | ||
|
||
// b | ||
System.out.println("\nb"); | ||
sum = 0; | ||
for (int i = 1; i <= 100; i++) { | ||
sum += i * i; | ||
} | ||
System.out.println(sum); | ||
|
||
// c | ||
int sum1 = 0; | ||
System.out.println("\nc"); | ||
for (int i = 0; i <= 20; i++) { | ||
sum1 += Math.pow(2, i); | ||
} | ||
System.out.println(sum1); | ||
|
||
|
||
// d | ||
System.out.println("\nd"); | ||
Scanner in = new Scanner(System.in); | ||
System.out.print("Enter a: "); | ||
int a = in.nextInt(); | ||
System.out.print("Enter b: "); | ||
int b = in.nextInt(); | ||
sum = 0; | ||
for (int i = a; i <= b; i++) { | ||
if (i % 2 == 1) { | ||
sum += i; | ||
} | ||
} | ||
System.out.println(sum); | ||
|
||
// e | ||
System.out.println("\ne"); | ||
int input = num; | ||
int sum2 = 0; | ||
|
||
for (int i = 0; i < ("" + input).length(); i++) { | ||
int num2 = Integer.parseInt(("" + ("" + input).charAt(i))); | ||
if (num2 % 2 == 1) { | ||
sum2 += num2; | ||
} | ||
} | ||
System.out.println(sum2); | ||
|
||
// 6.3 | ||
// a | ||
System.out.println("\n6.3"); | ||
|
||
int num1, num2, num3, num4, num5, num6, num7, num8; | ||
num1 = 18; | ||
num2 = 12; | ||
num3 = 21; | ||
num4 = 1; | ||
num5 = 5; | ||
num6 = 8; | ||
num7 = 20; | ||
num8 = 22; | ||
int[] nums = { num1, num2, num3, num4, num5, num6, num7, num8 }; | ||
|
||
System.out.println("\na"); | ||
|
||
int smallest = num1; | ||
int largest = num1; | ||
for (int i = 0; i < nums.length; i++) { | ||
if (nums[i] < smallest) { | ||
smallest = nums[i]; | ||
} else if (nums[i] > largest) { | ||
largest = nums[i]; | ||
} else { | ||
continue; | ||
} | ||
} | ||
|
||
System.out.println("Smallest: " + smallest); | ||
System.out.println("Largest: " + largest); | ||
|
||
// b | ||
System.out.println("\nb"); | ||
int even = 0; | ||
int odd = 0; | ||
for (int i = 0; i < nums.length; i++) { | ||
if (nums[i] % 2 == 1) { | ||
odd++; | ||
} else { | ||
even++; | ||
} | ||
} | ||
System.out.println("Evens: " + even); | ||
System.out.println("Odds: " + odd); | ||
|
||
// c | ||
System.out.println("\nc"); | ||
int total = 0; | ||
for (int i = 0; i < nums.length; i++) { | ||
int num = nums[i]; | ||
total += num; | ||
System.out.println(total); | ||
} | ||
|
||
// d | ||
System.out.println("\nd"); | ||
for (int i = 0; i < nums.length - 1; i++) { | ||
int number1 = nums[i]; | ||
int number2 = nums[i + 1]; | ||
if (number1 == number2) { | ||
System.out.println(number1); | ||
} | ||
} | ||
} | ||
} |