From 1fa1789ec056a086f5195f559292d4b9b7358571 Mon Sep 17 00:00:00 2001 From: reinardcox Date: Tue, 10 Mar 2015 09:19:02 -0400 Subject: [PATCH 1/4] Initial commit. Also added a folder ReinardCoxTestClass with my tested elements. --- .../EnterNumberChangeRoman.java | 106 ++++++++++++++++++ src/nyc/c4q/ac21/romancalc/FormatTest.java | 15 +++ src/nyc/c4q/ac21/romancalc/RomanNumerals.java | 7 +- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/ReinardCoxTestClass/EnterNumberChangeRoman.java create mode 100644 src/nyc/c4q/ac21/romancalc/FormatTest.java diff --git a/src/ReinardCoxTestClass/EnterNumberChangeRoman.java b/src/ReinardCoxTestClass/EnterNumberChangeRoman.java new file mode 100644 index 0000000..039bc85 --- /dev/null +++ b/src/ReinardCoxTestClass/EnterNumberChangeRoman.java @@ -0,0 +1,106 @@ +package ReinardCoxTestClass; + +import java.util.Scanner; + + +public class EnterNumberChangeRoman { + public static void main(String[] args) { + + if (true) { + System.out.print("Please enter a value: "); + Scanner userInput = new Scanner(System.in); + String letter = ""; + int numX; + numX = userInput.nextInt(); + + if (numX >= 1000){ + while ( numX >= 1000) { + letter += ("M"); + numX -= 1000; + } + }//System.out.println(numX); + + if (numX > 900 && numX < 1000){ + letter += ("CM"); + numX -= 900; + }//System.out.println(numX); + + if (numX >= 500) { + while ( numX >= 400) { + letter += ("D"); + numX -= 500; + } + } //System.out.println(numX); + + if (numX > 400 && numX < 500){ + letter += ("CD"); + numX -= 400; + }//System.out.println(numX); + + if (numX >=100) { + while ( numX >= 100) { + letter += ("C"); + numX -= 100; + } + }//System.out.println(numX); + + if (numX > 90 && numX < 100){ + letter += ("XC"); + numX -= 90; + }//System.out.println(numX); + + if (numX >=80) { + while ( numX >= 50) { + letter += ("L"); + numX -= 80; + } + }//System.out.println(numX); + + if (numX > 40 && numX < 50){ + letter += ("XC"); + numX -= 40; + }//System.out.println(numX); + + if (numX >=10) { + while ( numX >= 10) { + letter += ("X"); + numX -= 10; + } + }//System.out.println(numX); + + if (numX == 0) { + //System.out.println(letter); + } else if (numX == 9) { + letter += "IX"; + //System.out.println(letter); + } else if (numX >= 5 && numX < 9) { + letter += "V"; + numX -= 5; + while (numX >= 1) { + letter += ("I"); + numX -= 1; + } + + } else if (numX >= 4 && numX <= 4) { + letter += "IV"; + numX -= 4; + while (numX >= 1) { + letter += ("I"); + numX -= 1; + } + + //System.out.println(letter); + + } else { + + while (numX > 0) { + letter += ("I"); + numX -= 1; + } + }System.out.println(letter); + + + + } + } +} \ No newline at end of file diff --git a/src/nyc/c4q/ac21/romancalc/FormatTest.java b/src/nyc/c4q/ac21/romancalc/FormatTest.java new file mode 100644 index 0000000..c6ace51 --- /dev/null +++ b/src/nyc/c4q/ac21/romancalc/FormatTest.java @@ -0,0 +1,15 @@ +package nyc.c4q.ac21.romancalc; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class FormatTest { + + @Test + public void FormatModule() /*throws Exception*/ { + assertEquals("",RomanNumerals.format(0)); + + + } +} \ No newline at end of file diff --git a/src/nyc/c4q/ac21/romancalc/RomanNumerals.java b/src/nyc/c4q/ac21/romancalc/RomanNumerals.java index 12c285e..2a75cf8 100644 --- a/src/nyc/c4q/ac21/romancalc/RomanNumerals.java +++ b/src/nyc/c4q/ac21/romancalc/RomanNumerals.java @@ -12,8 +12,10 @@ public class RomanNumerals { * The value in Roman numerals. */ static String format(int value) { + + // TODO: Group 1: Write this function! - return "???"; + return null; } /** @@ -37,4 +39,7 @@ public static void main(String[] argv) { // TODO: Group 3: Write this function! // It should test that format() and parse() work correctly. } + + + } From 8191186d223f71243d95e5db744451c0f14e57cd Mon Sep 17 00:00:00 2001 From: reinardcox Date: Tue, 10 Mar 2015 10:45:12 -0400 Subject: [PATCH 2/4] Had to recompile the whole project --- Roman-calculator.iml | 11 ++ .../EnterNumberChangeRoman.java | 172 +++++++++--------- src/nyc/c4q/ac21/romancalc/FormatTest.java | 15 -- src/nyc/c4q/ac21/romancalc/RomanNumerals.java | 7 +- 4 files changed, 99 insertions(+), 106 deletions(-) create mode 100644 Roman-calculator.iml delete mode 100644 src/nyc/c4q/ac21/romancalc/FormatTest.java diff --git a/Roman-calculator.iml b/Roman-calculator.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Roman-calculator.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/ReinardCoxTestClass/EnterNumberChangeRoman.java b/src/ReinardCoxTestClass/EnterNumberChangeRoman.java index 039bc85..2238ca0 100644 --- a/src/ReinardCoxTestClass/EnterNumberChangeRoman.java +++ b/src/ReinardCoxTestClass/EnterNumberChangeRoman.java @@ -6,7 +6,9 @@ public class EnterNumberChangeRoman { public static void main(String[] args) { - if (true) { + while (true) { + + System.out.print("Please enter a value: "); Scanner userInput = new Scanner(System.in); String letter = ""; @@ -14,90 +16,90 @@ public static void main(String[] args) { numX = userInput.nextInt(); if (numX >= 1000){ - while ( numX >= 1000) { - letter += ("M"); - numX -= 1000; - } - }//System.out.println(numX); - - if (numX > 900 && numX < 1000){ - letter += ("CM"); - numX -= 900; - }//System.out.println(numX); - - if (numX >= 500) { - while ( numX >= 400) { - letter += ("D"); - numX -= 500; - } - } //System.out.println(numX); - - if (numX > 400 && numX < 500){ - letter += ("CD"); - numX -= 400; - }//System.out.println(numX); - - if (numX >=100) { - while ( numX >= 100) { - letter += ("C"); - numX -= 100; - } - }//System.out.println(numX); - - if (numX > 90 && numX < 100){ - letter += ("XC"); - numX -= 90; - }//System.out.println(numX); - - if (numX >=80) { - while ( numX >= 50) { - letter += ("L"); - numX -= 80; - } - }//System.out.println(numX); - - if (numX > 40 && numX < 50){ - letter += ("XC"); - numX -= 40; - }//System.out.println(numX); - - if (numX >=10) { - while ( numX >= 10) { - letter += ("X"); - numX -= 10; - } - }//System.out.println(numX); - - if (numX == 0) { - //System.out.println(letter); - } else if (numX == 9) { - letter += "IX"; - //System.out.println(letter); - } else if (numX >= 5 && numX < 9) { - letter += "V"; - numX -= 5; - while (numX >= 1) { - letter += ("I"); - numX -= 1; - } - - } else if (numX >= 4 && numX <= 4) { - letter += "IV"; - numX -= 4; - while (numX >= 1) { - letter += ("I"); - numX -= 1; - } - - //System.out.println(letter); - - } else { - - while (numX > 0) { - letter += ("I"); - numX -= 1; - } - }System.out.println(letter); + while ( numX >= 1000) { + letter += ("M"); + numX -= 1000; + } + }//System.out.println(numX); + + if (numX >= 900 && numX < 1000){ + letter += ("CM"); + numX -= 900; + }//System.out.println(numX); + + if (numX >= 500) { + while ( numX >= 500) { + letter += ("D"); + numX -= 500; + } + } //System.out.println(numX); + + if (numX >= 400 && numX < 500){ + letter += ("CD"); + numX -= 400; + }//System.out.println(numX); + + if (numX >=100) { + while ( numX >= 100) { + letter += ("C"); + numX -= 100; + } + }//System.out.println(numX); + + if (numX >= 90 && numX < 100){ + letter += ("XC"); + numX -= 90; + }//System.out.println(numX); + + if (numX >=50) { + while ( numX >= 50) { + letter += ("L"); + numX -= 50; + } + }//System.out.println(numX); + + if (numX >= 40 && numX < 80){ + letter += ("XL"); + numX -= 40; + }//System.out.println(numX); + + if (numX >=10 ) { + while ( numX >= 10) { + letter += ("X"); + numX -= 10; + } + }//System.out.println(numX); + + if (numX == 0) { + //System.out.println(letter); + } else if (numX == 9) { + letter += "IX"; + //System.out.println(letter); + } else if (numX >= 5 && numX < 9) { + letter += "V"; + numX -= 5; + while (numX >= 1) { + letter += ("I"); + numX -= 1; + } + + } else if (numX >= 4 && numX <= 4) { + letter += "IV"; + numX -= 4; + while (numX >= 1) { + letter += ("I"); + numX -= 1; + } + + //System.out.println(letter); + + } else { + + while (numX > 0) { + letter += ("I"); + numX -= 1; + } + }System.out.println(letter); diff --git a/src/nyc/c4q/ac21/romancalc/FormatTest.java b/src/nyc/c4q/ac21/romancalc/FormatTest.java deleted file mode 100644 index c6ace51..0000000 --- a/src/nyc/c4q/ac21/romancalc/FormatTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package nyc.c4q.ac21.romancalc; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class FormatTest { - - @Test - public void FormatModule() /*throws Exception*/ { - assertEquals("",RomanNumerals.format(0)); - - - } -} \ No newline at end of file diff --git a/src/nyc/c4q/ac21/romancalc/RomanNumerals.java b/src/nyc/c4q/ac21/romancalc/RomanNumerals.java index 2a75cf8..12c285e 100644 --- a/src/nyc/c4q/ac21/romancalc/RomanNumerals.java +++ b/src/nyc/c4q/ac21/romancalc/RomanNumerals.java @@ -12,10 +12,8 @@ public class RomanNumerals { * The value in Roman numerals. */ static String format(int value) { - - // TODO: Group 1: Write this function! - return null; + return "???"; } /** @@ -39,7 +37,4 @@ public static void main(String[] argv) { // TODO: Group 3: Write this function! // It should test that format() and parse() work correctly. } - - - } From ef657b425ccf35c81571f138677a3099a22d750c Mon Sep 17 00:00:00 2001 From: MadelynTav Date: Wed, 11 Mar 2015 20:19:16 -0400 Subject: [PATCH 3/4] Group1 Addition --- d.java | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 d.java diff --git a/d.java b/d.java new file mode 100644 index 0000000..d3b056d --- /dev/null +++ b/d.java @@ -0,0 +1,133 @@ +package nyc.c4q.madelyntav; + +/** + * Created by c4q- hyunj0 and MadelynTav on 3/11/15. + */ +import java.util.Scanner; +public class d { + + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + + while (true) { + //Take input from user + //Program will print given roman numeral which is determined after user input is converted by the code + //in the program. + + int number = input.nextInt(); + String romanNumeral = ""; + + //If the input by the user is greater than or equal to 4000 the program will prompt + //the user to try again and the program will run again. + + while (number >= 4000) { + System.out.print("Try again"); + break; + } + // For numbers smaller than 4000 and equal to or greater than 1000 the program will subtract + //one thousand each time until the number reaches zero. For each one thousand that the + //program subtracts it will replace the 1000 with an M + while (number < 4000 && number >= 1000) { + number -= 1000; + romanNumeral += "M"; + } + + //For numbers smaller than one thousand and greater than or equal to 500, the program + //will subtract 900 from the input each time until 900. + //Each 900 that is subtracted will be replaced by a CM. + //If the number is smaller than 900 the program will subtract 500, and replace the 500 with a D + + while (number < 1000 && number >= 500) { + if (number >= 900) { + number -= 900; + romanNumeral += "CM"; + } else { + number -= 500; + romanNumeral += "D"; + } + } + + //For numbers smaller than 500 and greater than or equal to 100: First the program will subtract 400 while the number + // is greater than or equal to 400, and replace it with a CD. + // but if the number is lower than 400, 100 will be subtracted while the number is still within the range of + // 400 and 100, each 100 that is removed will be replaced by a C. + while (number < 500 && number >= 100) { + if (number >= 400) { + number -= 400; + romanNumeral += "CD"; + } else { + number -= 100; + romanNumeral += "C"; + } + } + + ///For numbers smaller than 100 and greater than or equal to 50. + // The program will check if the number is smaller 100 and greater + // than or equal to 90. If it is, then the program will take away 90 and replace it by XC. If the input + //is smaller than 90 then the program will subtract 50 and replace that 50 with an L. + while (number < 100 && number >= 50) { + if (number >= 90) { + number -= 90; + romanNumeral += "XC"; + } else { + number -= 50; + romanNumeral += "L"; + } + } + + //Then the program will check if the input includes numbers between 50 and equal to or greater than 10. + // if the number is between 50 and equal to or greater than 40 the program will remove 40 and replace it + // with XL. But if the number is less than 40 the program will instead replace each 10 it can remove with + //an X. + while (number < 50 && number >= 10) { + if (number >= 40) { + number -= 40; + romanNumeral += "XL"; + } else { + number -= 10; + romanNumeral += "X"; + } + } + + //Then the program will check numbers between 10 and greater than or equal to 5. If the number is between + //10 and greater than or equal to 9 then the program will subtract 9 and replace that 9 with an IX. + //But if the number is less than 9, then the program will subtract 5 and replace it with a V. + + while (number < 10 && number >= 5) { + if (number >= 9) { + number -= 9; + romanNumeral += "IX"; + } else { + number -= 5; + romanNumeral += "V"; + } + } + + //Then the program will check for numbers smaller than 5 and greater than or equal to 1 + // if the number is greater than or equal to 4 the program will subtract 4 and replace it with an IV. If + // the number is less than 4, the program will subtract one and replace each one with an I. + while (number < 5 && number >= 1) { + if (number >= 4) { + number -= 4; + romanNumeral += "IV"; + } else { + number -= 1; + romanNumeral += "I"; + } + } + //If the user input is smaller than zero (A negative number), the program will print "You cannot enter a + //negative number and the program breaks. + while (number < 0) { + System.out.print("You cannot enter a negative number"); + break; + } +//Once the program converts all of the numbers into roman numerals, it will print out the number in Roman Numeral form. + + System.out.println(romanNumeral); + + + + } + } + + } From 0289fb2f4f280d5a92b98ac552862feb56f83c1b Mon Sep 17 00:00:00 2001 From: MadelynTav Date: Wed, 11 Mar 2015 20:21:51 -0400 Subject: [PATCH 4/4] additions --- Counter2.java | 24 ++++++++++++++++++++++++ Counting.java | 20 ++++++++++++++++++++ Fizz.java | 39 +++++++++++++++++++++++++++++++++++++++ Main.java | 11 +++++++++++ 4 files changed, 94 insertions(+) create mode 100644 Counter2.java create mode 100644 Counting.java create mode 100644 Fizz.java create mode 100644 Main.java diff --git a/Counter2.java b/Counter2.java new file mode 100644 index 0000000..2009f30 --- /dev/null +++ b/Counter2.java @@ -0,0 +1,24 @@ +package nyc.c4q.madelyntav; + +/** + * Created by c4q-madelyntavarez on 3/10/15. + */ +import java.util.Scanner; +public class Counter2 { + public static void main(String[] args){ + Scanner scanner= new Scanner (System.in); + System.out.println("Give me a starting number"); + int start=scanner.nextInt(); + + System.out.println("Give me another ending number"); + int end=scanner.nextInt(); + + System.out.println("Give me an increment number"); + int inc=scanner.nextInt(); + + for (int i=start; i<=end; i= i+inc) { + System.out.println(i); + + } + } +} diff --git a/Counting.java b/Counting.java new file mode 100644 index 0000000..4995dc6 --- /dev/null +++ b/Counting.java @@ -0,0 +1,20 @@ +package nyc.c4q.madelyntav; + +/** + * Created by c4q-madelyntavarez on 3/10/15. + */ +import java.util.Scanner; + +public class Counting { + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + System.out.println("Give me a number"); + int max= input.nextInt(); + + for (int i = 0; i <= max; i++) { + System.out.print(i+" "); + + } + } +} + diff --git a/Fizz.java b/Fizz.java new file mode 100644 index 0000000..cf83ce8 --- /dev/null +++ b/Fizz.java @@ -0,0 +1,39 @@ +package nyc.c4q.madelyntav; + +/** + * Created by c4q-madelyntavarez on 3/10/15. + */ +import java.util.Scanner; + +public class Fizz { + public static void main(String[] args){ + + Scanner scanner = new Scanner(System.in); + + for (int i=1; i<101; i++) { + if ((i % 3==0 && i % 5==0)) + System.out.println("Fizz Buzz"); + else if (i % 5 == 0) { + System.out.println("Buzz"); + } + + else if (i % 3 == 0) { + System.out.println("Fizz"); + } + + + + else + System.out.println(i); + } + + + } +} + + + + + + + diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..5cd9e95 --- /dev/null +++ b/Main.java @@ -0,0 +1,11 @@ +package nyc.c4q.madelyntav; +import java.util.Scanner; + +public class Main { + + public static void main(String[] args) { + for (int i=0;i<3;i++); + System.out.print("i"); + // write your code here + } +}